Skip to content

Commit

Permalink
add test project.
Browse files Browse the repository at this point in the history
  • Loading branch information
omid-ahmadpour committed Feb 24, 2024
1 parent 6df4f7e commit 3027bc3
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
38 changes: 38 additions & 0 deletions PolyCache.Tests/CacheKeyTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using PolyCache.Cache;

namespace PolyCache.Tests
{
[TestFixture]
public class CacheKeyTests
{
[Test]
public void Constructor_ShouldInitializeKeyAndPrefixes()
{
var cacheKey = new CacheKey("testKey", "prefix1", "prefix2");

Assert.AreEqual("testKey", cacheKey.Key);
Assert.Contains("prefix1", cacheKey.Prefixes);
Assert.Contains("prefix2", cacheKey.Prefixes);
}

[Test]
public void Create_ShouldReturnNewCacheKeyWithFormattedKeyAndPrefixes()
{
var cacheKey = new CacheKey("{0}Key", "{0}Prefix");
var newCacheKey = cacheKey.Create(o => o.ToString(), "test");

Assert.AreEqual("testKey", newCacheKey.Key);
Assert.Contains("testPrefix", newCacheKey.Prefixes);
}

[Test]
public void Create_ShouldReturnNewCacheKeyWithSameKeyAndPrefixes_WhenNoKeyObjectsProvided()
{
var cacheKey = new CacheKey("testKey", "testPrefix");
var newCacheKey = cacheKey.Create(o => o.ToString());

Assert.AreEqual("testKey", newCacheKey.Key);
Assert.Contains("testPrefix", newCacheKey.Prefixes);
}
}
}
28 changes: 28 additions & 0 deletions PolyCache.Tests/PolyCache.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\PolyCache\PolyCache.csproj" />
</ItemGroup>

<ItemGroup>
<Using Include="NUnit.Framework" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions PolyCache.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
redis-docker-compose.yml = redis-docker-compose.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PolyCache.Tests", "PolyCache.Tests\PolyCache.Tests.csproj", "{2E952CC7-1046-40FB-9BDB-E3FC193F2D0E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,6 +29,10 @@ Global
{ABADBAA8-CAE8-4696-A317-23286FBA4129}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ABADBAA8-CAE8-4696-A317-23286FBA4129}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ABADBAA8-CAE8-4696-A317-23286FBA4129}.Release|Any CPU.Build.0 = Release|Any CPU
{2E952CC7-1046-40FB-9BDB-E3FC193F2D0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E952CC7-1046-40FB-9BDB-E3FC193F2D0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E952CC7-1046-40FB-9BDB-E3FC193F2D0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E952CC7-1046-40FB-9BDB-E3FC193F2D0E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 3027bc3

Please sign in to comment.