Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 10.0.x
- name: Restore dependencies
run: dotnet restore Homestead
- name: Build
Expand Down
10 changes: 5 additions & 5 deletions Homestead/Client/Homestead.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand All @@ -11,10 +11,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.11" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.0" />
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Homestead/Client/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

protected override async Task OnInitializedAsync()
{
Lobby.PlayerId = await localStorage.GetItemAsync<string>("PlayerId");
Lobby.PlayerId = await localStorage.GetItemAsync<string>("PlayerId") ?? string.Empty;
if (string.IsNullOrEmpty(Lobby.PlayerId))
{
Lobby.PlayerId = Guid.NewGuid().ToString();
Expand Down
10 changes: 5 additions & 5 deletions Homestead/Homestead.Client.Tests/Homestead.Client.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="4.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="4.0.2" />
<PackageReference Include="coverlet.collector" Version="6.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Homestead/Homestead.Client.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
41 changes: 20 additions & 21 deletions Homestead/Homestead.Shared.Tests/GameEngineTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NuGet.Frameworks;


namespace Homestead.Shared.Tests
{
[TestClass]
Expand Down Expand Up @@ -70,7 +69,7 @@ public void DrawFromDiscardTest()
game = engine.ProcessAction(game, action);
Assert.IsFalse(game.DiscardPile.Any());
Assert.IsTrue(game.Players[game.ActivePlayer].Hand.Any());
Assert.IsTrue(game.Players[game.ActivePlayer].Hand[0] is Cards.Well);
Assert.AreEqual(Cards.Well, game.Players[game.ActivePlayer].Hand[0]);

Assert.IsFalse(game.AvailableActions.Any(a => a.Type is PlayerAction.ActionType.DrawFromDeck));
Assert.IsFalse(game.AvailableActions.Any(a => a.Type is PlayerAction.ActionType.DrawFromDiscard));
Expand All @@ -97,11 +96,11 @@ public void DrawFromDiscardWhenMultipleOfSameTypeExist()

game = engine.ProcessAction(game, action);
Assert.IsTrue(game.Players[game.ActivePlayer].Hand.Any());
Assert.IsTrue(game.Players[game.ActivePlayer].Hand[0] is Cards.Well);
Assert.AreEqual(Cards.Well, game.Players[game.ActivePlayer].Hand[0]);

Assert.IsTrue(game.DiscardPile.Any());
Assert.IsTrue(game.DiscardPile.First() is Cards.Well);
Assert.IsTrue(game.DiscardPile.Last() is Cards.Wood);
Assert.AreEqual(Cards.Well, game.DiscardPile.First());
Assert.AreEqual(Cards.Wood, game.DiscardPile.Last());
}

// Draw from discard with no discard
Expand Down Expand Up @@ -130,7 +129,7 @@ public void PlayCardWithoutCardInHandThrowsKeyNotFound()
PlayerAction action = new(PlayerAction.ActionType.Play, game.ActivePlayer);
action.PlayerCard = Cards.Well;

Assert.ThrowsException<KeyNotFoundException>(() => engine.ProcessAction(game, action));
Assert.Throws<KeyNotFoundException>(() => engine.ProcessAction(game, action));
}

// Active Player reverts to 1 after 4
Expand All @@ -152,13 +151,13 @@ public void PlayCardGiveCard()
action.TargetCard = Cards.Well;
//action.PlayerCard = "Give";

Assert.AreEqual(2, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(0, game.Players[2].Hand.Count);
Assert.HasCount(2, game.Players[game.ActivePlayer].Hand);
Assert.IsEmpty(game.Players[2].Hand);

game = engine.ProcessAction(game, action);

Assert.AreEqual(0, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(1, game.Players[2].Hand.Count);
Assert.IsEmpty(game.Players[game.ActivePlayer].Hand);
Assert.HasCount(1, game.Players[2].Hand);
}

[TestMethod]
Expand All @@ -173,13 +172,13 @@ public void PlayCardGiveCardWithoutAdditionalCardInHand()
PlayerAction action = new(PlayerAction.ActionType.Play, game.ActivePlayer);
action.PlayerCard = Cards.GoodNeighbor;

Assert.AreEqual(1, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(0, game.Players[2].Hand.Count);
Assert.HasCount(1, game.Players[game.ActivePlayer].Hand);
Assert.IsEmpty(game.Players[2].Hand);

Assert.ThrowsException<NullReferenceException>(() => engine.ProcessAction(game, action));
Assert.Throws<NullReferenceException>(() => engine.ProcessAction(game, action));

Assert.AreEqual(0, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(0, game.Players[2].Hand.Count);
Assert.IsEmpty(game.Players[game.ActivePlayer].Hand);
Assert.IsEmpty(game.Players[2].Hand);
}

[TestMethod]
Expand All @@ -198,13 +197,13 @@ public void PlayCardStealCard()
action.TargetCard = Cards.Well;
//action.PlayerCard = "Give";

Assert.AreEqual(1, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(1, game.Players[2].Hand.Count);
Assert.HasCount(1, game.Players[game.ActivePlayer].Hand);
Assert.HasCount(1, game.Players[2].Hand);

game = engine.ProcessAction(game, action);

Assert.AreEqual(1, game.Players[game.ActivePlayer].Hand.Count);
Assert.AreEqual(0, game.Players[2].Hand.Count);
Assert.HasCount(1, game.Players[game.ActivePlayer].Hand);
Assert.IsEmpty(game.Players[2].Hand);
}

// Player cannot draw two cards from deck
Expand Down Expand Up @@ -243,7 +242,7 @@ public void Wolves()
PlayerAction action = new(PlayerAction.ActionType.Play, game.ActivePlayer, Cards.WolfAll);

game = engine.ProcessAction(game, action);
Assert.AreEqual(4, game.AvailableActions.Count);
Assert.HasCount(4, game.AvailableActions);
Assert.IsTrue(game.AvailableActions.All(a => a.Type is PlayerAction.ActionType.Discard));
}

Expand Down
9 changes: 5 additions & 4 deletions Homestead/Homestead.Shared.Tests/GameLookupTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ namespace Homestead.Shared.Tests
[TestClass]
public class GameLookupTest
{
GameLookup _lookup { get; set; }
GameLookupTest(GameLookup lookup)
GameLookup _lookup { get; set; } = new GameLookup();

[TestInitialize]
public void Initialize()
{
_lookup = lookup;
_lookup = new GameLookup();
}
[TestInitialize]

[TestMethod]
public void addGame()
Expand Down
4 changes: 2 additions & 2 deletions Homestead/Homestead.Shared.Tests/GameTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public void CreateGame()
GameEngineWithActions engine = new();
Game game = engine.Start("test");

Assert.AreEqual(4, game.Players.Count);
Assert.IsTrue(game.Players[3].Name != null);
Assert.HasCount(4, game.Players);
Assert.IsNotNull(game.Players[3].Name);
}
}
}
10 changes: 5 additions & 5 deletions Homestead/Homestead.Shared.Tests/Homestead.Shared.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="4.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="4.0.2" />
<PackageReference Include="coverlet.collector" Version="6.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion Homestead/Homestead.Shared.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;
global using Microsoft.VisualStudio.TestTools.UnitTesting;

[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
8 changes: 4 additions & 4 deletions Homestead/Server/Homestead.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="6.0.11" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Homestead/Shared/Actions/ActionPlayCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void DoDisaster(string card, int? targetPlayer)
CurrentPlayer.Hand.Remove(card);
}

private bool RemoveCardsBasedOnDisaster(int playerNumber, string impactedCard, string preventionCard)
private bool RemoveCardsBasedOnDisaster(int playerNumber, string impactedCard, string? preventionCard)
{
if (preventionCard==null || !RemoveCardFromPlayersHand(playerNumber, preventionCard))
{
Expand Down
1 change: 0 additions & 1 deletion Homestead/Shared/Cards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public static class Cards
static Cards()
{
int extreme = 20;
int tons = 15;
int lots = 10;
int some = 2;
int few = 1;
Expand Down
4 changes: 2 additions & 2 deletions Homestead/Shared/Homestead.Shared.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.2" />
<PackageReference Include="RandomNameGeneratorLibrary" Version="1.2.2" />
</ItemGroup>

Expand Down
Loading