-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
112 additions
and
2 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
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
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
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
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,59 @@ | ||
using dsstats.shared; | ||
|
||
namespace dsstats.pickban.tests | ||
{ | ||
[TestClass] | ||
public class PickBanTests | ||
{ | ||
[TestMethod] | ||
public void InitializeTest() | ||
{ | ||
var pickBanState = new PickBanState(Guid.NewGuid(), PickBanMode.Commanders, GameMode.Commanders, 2, 6); | ||
|
||
Assert.AreEqual(0, pickBanState.Visitors); | ||
Assert.AreEqual(0, pickBanState.Bans.Count); | ||
Assert.AreEqual(0, pickBanState.Picks.Count); | ||
Assert.IsFalse(pickBanState.BansPublic); | ||
Assert.IsFalse(pickBanState.PicksPublic); | ||
} | ||
|
||
[TestMethod] | ||
public void SetBan_AddsBanCorrectly() | ||
{ | ||
// Arrange | ||
var pickBanState = new PickBanState(Guid.NewGuid(), PickBanMode.Commanders, GameMode.Commanders, 2, 6); | ||
var ban = new PickBan { Slot = 1, Commander = Commander.Abathur, Locked = false }; | ||
|
||
// Act | ||
var dto = pickBanState.SetBan(ban); | ||
|
||
// Assert | ||
Assert.IsNotNull(dto); | ||
Assert.AreEqual(1, pickBanState.Bans.Count); | ||
Assert.AreEqual(ban.Slot, pickBanState.Bans[0].Slot); | ||
Assert.AreEqual(ban.Commander, pickBanState.Bans[0].Commander); | ||
Assert.AreEqual(ban.Locked, pickBanState.Bans[0].Locked); | ||
} | ||
|
||
[TestMethod] | ||
public void SetPick_AddsPickCorrectly() | ||
{ | ||
// Arrange | ||
var pickBanState = new PickBanState(Guid.NewGuid(), PickBanMode.Commanders, GameMode.Commanders, 2, 6); | ||
pickBanState.SetBan(new PickBan { Slot = 1, Commander = Commander.Abathur, Locked = true }); | ||
pickBanState.SetBan(new PickBan { Slot = 2, Commander = Commander.Alarak, Locked = true }); | ||
pickBanState.SetBan(new PickBan { Slot = 3, Commander = Commander.Artanis, Locked = true }); | ||
var pick = new PickBan { Slot = 1, Commander = Commander.Stukov, Locked = true }; | ||
|
||
// Act | ||
var dto = pickBanState.SetPick(pick); | ||
|
||
// Assert | ||
Assert.IsNotNull(dto); | ||
Assert.AreEqual(1, pickBanState.Picks.Count); | ||
Assert.AreEqual(pick.Slot, pickBanState.Picks[0].Slot); | ||
Assert.AreEqual(pick.Commander, pickBanState.Picks[0].Commander); | ||
Assert.AreEqual(pick.Locked, pickBanState.Picks[0].Locked); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/tests/dsstats.pickban.tests/dsstats.pickban.tests.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,27 @@ | ||
<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="MSTest.TestAdapter" Version="3.1.1" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\dsstats.pickban\dsstats.pickban.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" /> | ||
</ItemGroup> | ||
|
||
</Project> |