Skip to content

Commit

Permalink
Merge pull request #248 from dmitrii-kiselev/feature/unit-tests
Browse files Browse the repository at this point in the history
feat(unit-tests): create the unit test project
  • Loading branch information
VahidN authored Sep 26, 2024
2 parents 10929ea + 0fc3a44 commit 57f5908
Show file tree
Hide file tree
Showing 7 changed files with 2,328 additions and 0 deletions.
15 changes: 15 additions & 0 deletions EFCoreSecondLevelCacheInterceptor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Issue154", "src\Tests\Issue
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Issue192", "src\Tests\Issues\Issue192\Issue192.csproj", "{72079056-6752-43FD-BA53-E0BF5EFFF2C2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFCoreSecondLevelCacheInterceptor.UnitTests", "src\Tests\EFCoreSecondLevelCacheInterceptor.UnitTests\EFCoreSecondLevelCacheInterceptor.UnitTests.csproj", "{F77DD140-4762-426E-8FE0-3AD34DE3867A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -246,6 +248,18 @@ Global
{72079056-6752-43FD-BA53-E0BF5EFFF2C2}.Release|x64.Build.0 = Release|Any CPU
{72079056-6752-43FD-BA53-E0BF5EFFF2C2}.Release|x86.ActiveCfg = Release|Any CPU
{72079056-6752-43FD-BA53-E0BF5EFFF2C2}.Release|x86.Build.0 = Release|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Debug|x64.ActiveCfg = Debug|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Debug|x64.Build.0 = Debug|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Debug|x86.ActiveCfg = Debug|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Debug|x86.Build.0 = Debug|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Release|Any CPU.Build.0 = Release|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Release|x64.ActiveCfg = Release|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Release|x64.Build.0 = Release|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Release|x86.ActiveCfg = Release|Any CPU
{F77DD140-4762-426E-8FE0-3AD34DE3867A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{EB8ADB13-3CE7-4A85-A70C-229972476023} = {CDC8E8F6-5261-4CF2-846E-F8C438438663}
Expand All @@ -266,5 +280,6 @@ Global
{C3DA6825-3AA1-43A9-B665-38CB4B2A69D6} = {4E1F72D1-5A8F-4569-A57A-42E706B6A318}
{93359BAE-B026-4680-9818-D06EE408B910} = {4E1F72D1-5A8F-4569-A57A-42E706B6A318}
{72079056-6752-43FD-BA53-E0BF5EFFF2C2} = {4E1F72D1-5A8F-4569-A57A-42E706B6A318}
{F77DD140-4762-426E-8FE0-3AD34DE3867A} = {C250B77E-090A-4FBE-BB73-2D91774A6929}
EndGlobalSection
EndGlobal
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>
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);
}
}
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);
}
}
Loading

0 comments on commit 57f5908

Please sign in to comment.