From 35b7c351671f424462de4c6926d4fbaa02c22cda Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Thu, 17 Aug 2023 00:58:44 -0700 Subject: [PATCH] fix: Fixes tests to use C# 11 syntax (#1462) --- Projects/Server.Tests/Server.Tests.csproj | 2 +- .../Tests/Collections/PooledRefQueueTests.cs | 12 +++++++--- .../Engines/ML Quests/MLQuestPacketTests.cs | 12 ++++++---- .../Tests/Multis/Boats/BoatPacketTests.cs | 22 +++++++++++++++---- .../UOContent.Tests/UOContent.Tests.csproj | 2 +- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/Projects/Server.Tests/Server.Tests.csproj b/Projects/Server.Tests/Server.Tests.csproj index 71402d4100..20e7f2b98c 100644 --- a/Projects/Server.Tests/Server.Tests.csproj +++ b/Projects/Server.Tests/Server.Tests.csproj @@ -4,7 +4,7 @@ Debug;Release;Analyze - + diff --git a/Projects/Server.Tests/Tests/Collections/PooledRefQueueTests.cs b/Projects/Server.Tests/Tests/Collections/PooledRefQueueTests.cs index 4ec3133945..ecc08a60e7 100644 --- a/Projects/Server.Tests/Tests/Collections/PooledRefQueueTests.cs +++ b/Projects/Server.Tests/Tests/Collections/PooledRefQueueTests.cs @@ -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(); diff --git a/Projects/UOContent.Tests/Tests/Engines/ML Quests/MLQuestPacketTests.cs b/Projects/UOContent.Tests/Tests/Engines/ML Quests/MLQuestPacketTests.cs index f1f50720e3..12820b098d 100644 --- a/Projects/UOContent.Tests/Tests/Engines/ML Quests/MLQuestPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Engines/ML Quests/MLQuestPacketTests.cs @@ -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, @@ -17,8 +19,8 @@ private class MockedRace( int maleGhostBody, int femaleGhostBody, Expansion requiredExpansion - ) - : Race(raceID, + ) : base( + raceID, raceIndex, name, pluralName, @@ -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(); diff --git a/Projects/UOContent.Tests/Tests/Multis/Boats/BoatPacketTests.cs b/Projects/UOContent.Tests/Tests/Multis/Boats/BoatPacketTests.cs index 3f5772eb0a..82be1a712f 100644 --- a/Projects/UOContent.Tests/Tests/Multis/Boats/BoatPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Multis/Boats/BoatPacketTests.cs @@ -102,19 +102,33 @@ public void TestDisplayBoatHS() AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); } - private class TestBoat(Serial serial, List list, List notContainedList) : BaseBoat(serial) + private class TestBoat : BaseBoat { + private readonly List _list; + private readonly List _notContainedList; + + public TestBoat(Serial serial, List list, List notContainedList) : base(serial) + { + _list = list; + _notContainedList = notContainedList; + } + public override MultiComponentList Components { get; } = new(new List()); - 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(list)); + new(this, true, new Map.PooledEnumerable(_list)); } - private class MockedMobile(Serial serial) : Mobile(serial) + private class MockedMobile : Mobile { public HashSet 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); diff --git a/Projects/UOContent.Tests/UOContent.Tests.csproj b/Projects/UOContent.Tests/UOContent.Tests.csproj index 6d6f86bed0..2345a14af6 100644 --- a/Projects/UOContent.Tests/UOContent.Tests.csproj +++ b/Projects/UOContent.Tests/UOContent.Tests.csproj @@ -4,7 +4,7 @@ Debug;Release;Analyze - +