-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from dmitrii-kiselev/feature/unit-tests
feat(unit-tests): create the unit test project
- Loading branch information
Showing
7 changed files
with
2,328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...eSecondLevelCacheInterceptor.UnitTests/EFCoreSecondLevelCacheInterceptor.UnitTests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<AssemblyName>EFCoreSecondLevelCacheInterceptor.UnitTests</AssemblyName> | ||
<PackageId>EFCoreSecondLevelCacheInterceptor.UnitTests</PackageId> | ||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> | ||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> | ||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> | ||
<IsPackable>false</IsPackable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector" Version="6.0.2"/> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/> | ||
<PackageReference Include="Moq" Version="4.20.72" /> | ||
<PackageReference Include="xunit" Version="2.9.1"/> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Xunit"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\EFCoreSecondLevelCacheInterceptor\EFCoreSecondLevelCacheInterceptor.csproj" /> | ||
</ItemGroup> | ||
</Project> |
36 changes: 36 additions & 0 deletions
36
src/Tests/EFCoreSecondLevelCacheInterceptor.UnitTests/EFTableColumnInfoTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace EFCoreSecondLevelCacheInterceptor.UnitTests; | ||
|
||
public class EFTableColumnInfoTests | ||
{ | ||
[Fact] | ||
public void ToString_ReturnsFormattedString_WithValidProperties() | ||
{ | ||
// Arrange | ||
var columnInfo = new EFTableColumnInfo | ||
{ | ||
Ordinal = 1, | ||
Name = "ColumnName", | ||
DbTypeName = "DbType", | ||
TypeName = "Type" | ||
}; | ||
|
||
// Act | ||
var result = columnInfo.ToString(); | ||
|
||
// Assert | ||
Assert.Equal("Ordinal: 1, Name: ColumnName, DbTypeName: DbType, TypeName= Type.", result); | ||
} | ||
|
||
[Fact] | ||
public void ToString_ReturnsFormattedString_WithDefaultProperties() | ||
{ | ||
// Arrange | ||
var columnInfo = new EFTableColumnInfo(); | ||
|
||
// Act | ||
var result = columnInfo.ToString(); | ||
|
||
// Assert | ||
Assert.Equal("Ordinal: 0, Name: , DbTypeName: , TypeName= .", result); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/Tests/EFCoreSecondLevelCacheInterceptor.UnitTests/EFTableRowTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
namespace EFCoreSecondLevelCacheInterceptor.UnitTests; | ||
|
||
public class EFTableRowTests | ||
{ | ||
[Fact] | ||
public void Constructor_ShouldInitializeValues() | ||
{ | ||
// Arrange | ||
var values = new List<object> { 1, "test" }; | ||
|
||
// Act | ||
var row = new EFTableRow(values); | ||
|
||
// Assert | ||
Assert.Equal(values, row.Values); | ||
} | ||
|
||
[Fact] | ||
public void GetValues_ShouldReturnExpectedValues() | ||
{ | ||
// Arrange | ||
var expected = new List<object> { 1, "test" }; | ||
var row = new EFTableRow(expected); | ||
|
||
// Act | ||
var actual = row.Values; | ||
|
||
// Assert | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Fact] | ||
public void GetDepth_ShouldReturnExpectedCount() | ||
{ | ||
// Arrange | ||
const int expected = 1; | ||
var values = new List<object> { 1, "test" }; | ||
var row = new EFTableRow(values) { Depth = expected }; | ||
|
||
// Act | ||
var actual = row.Depth; | ||
|
||
// Assert | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Fact] | ||
public void GetFieldCount_ShouldReturnExpectedCount() | ||
{ | ||
// Arrange | ||
var values = new List<object> { 1, "test" }; | ||
var row = new EFTableRow(values); | ||
|
||
// Act | ||
var fieldCount = row.FieldCount; | ||
|
||
// Assert | ||
Assert.Equal(values.Count, fieldCount); | ||
} | ||
|
||
[Fact] | ||
public void GetByIndexer_ShouldReturnExpectedValue() | ||
{ | ||
// Arrange | ||
var expected = Guid.NewGuid().ToString(); | ||
var values = new List<object> { 1, expected }; | ||
var row = new EFTableRow(values); | ||
|
||
// Act | ||
var value = row[1]; | ||
|
||
// Assert | ||
Assert.Equal(expected, value); | ||
} | ||
} |
Oops, something went wrong.