Skip to content

Commit

Permalink
Add unit test for singleton pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamyab7 committed Jun 17, 2023
1 parent b31a623 commit dac6301
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
7 changes: 6 additions & 1 deletion tests/DesignPatterns.Tests/DesignPatterns.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand All @@ -10,11 +10,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Singleton\Singleton.csproj" />
</ItemGroup>

</Project>
20 changes: 20 additions & 0 deletions tests/DesignPatterns.Tests/SingletonTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using FluentAssertions;
using Singleton;

namespace DesignPatterns.Tests;

public class SingletonTests
{
[Test]
public void BothInstanceShouldBeSame()
{
// arrange
SingletonSample s1 = SingletonSample.GetInstance();
SingletonSample s2 = SingletonSample.GetInstance();

// act

// assert
s1.Should().BeEquivalentTo(s2);
}
}
16 changes: 0 additions & 16 deletions tests/DesignPatterns.Tests/UnitTest1.cs

This file was deleted.

0 comments on commit dac6301

Please sign in to comment.