Skip to content

Commit

Permalink
fix: Fixes tests to use C# 11 syntax (#1462)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Aug 17, 2023
1 parent 2c8d545 commit 35b7c35
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Projects/Server.Tests/Server.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Configurations>Debug;Release;Analyze</Configurations>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0" />
<ProjectReference Include="..\Server\Server.csproj" />
Expand Down
12 changes: 9 additions & 3 deletions Projects/Server.Tests/Tests/Collections/PooledRefQueueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ namespace Server.Tests;

public sealed class PooledRefQueueTests : IDisposable
{
private class MockedRandomSource(int queueCount, int mockedValue) : IRandomSource
private class MockedRandomSource : IRandomSource
{
private int _queueCount = queueCount;
private int _mockedValue = mockedValue;
private int _queueCount;
private int _mockedValue;

public MockedRandomSource(int queueCount, int mockedValue)
{
_queueCount = queueCount;
_mockedValue = mockedValue;
}

public int Next() => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ namespace Server.Engines.MLQuests;

public class MLQuestPacketTests
{
private class MockedRace(
private class MockedRace : Race
{
public MockedRace(
int raceID,
int raceIndex,
string name,
Expand All @@ -17,8 +19,8 @@ private class MockedRace(
int maleGhostBody,
int femaleGhostBody,
Expansion requiredExpansion
)
: Race(raceID,
) : base(
raceID,
raceIndex,
name,
pluralName,
Expand All @@ -28,7 +30,9 @@ Expansion requiredExpansion
femaleGhostBody,
requiredExpansion
)
{
{
}

public override bool ValidateHair(bool female, int itemID) => throw new NotImplementedException();

public override int RandomHair(bool female) => throw new NotImplementedException();
Expand Down
22 changes: 18 additions & 4 deletions Projects/UOContent.Tests/Tests/Multis/Boats/BoatPacketTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,33 @@ public void TestDisplayBoatHS()
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
}

private class TestBoat(Serial serial, List<IEntity> list, List<IEntity> notContainedList) : BaseBoat(serial)
private class TestBoat : BaseBoat
{
private readonly List<IEntity> _list;
private readonly List<IEntity> _notContainedList;

public TestBoat(Serial serial, List<IEntity> list, List<IEntity> notContainedList) : base(serial)
{
_list = list;
_notContainedList = notContainedList;
}

public override MultiComponentList Components { get; } = new(new List<MultiTileEntry>());

public override bool Contains(int x, int y) => !notContainedList.Any(e => e.X == x && e.Y == y);
public override bool Contains(int x, int y) => !_notContainedList.Any(e => e.X == x && e.Y == y);

public override MovingEntitiesEnumerable GetMovingEntities(bool includeBoat = false) =>
new(this, true, new Map.PooledEnumerable<IEntity>(list));
new(this, true, new Map.PooledEnumerable<IEntity>(_list));
}

private class MockedMobile(Serial serial) : Mobile(serial)
private class MockedMobile : Mobile
{
public HashSet<IEntity> CanSeeEntities = new();

public MockedMobile(Serial serial) : base(serial)
{
}

public override bool CanSee(Mobile m) => m == this;

public override bool CanSee(Item i) => CanSeeEntities.Contains(i);
Expand Down
2 changes: 1 addition & 1 deletion Projects/UOContent.Tests/UOContent.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Configurations>Debug;Release;Analyze</Configurations>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0" />
<ProjectReference Include="..\Server\Server.csproj" />
Expand Down

0 comments on commit 35b7c35

Please sign in to comment.