test: fix shared state, CI-vacuous tests and harness duplication (#2722)
Follow-up to #2721. It fixes how the remaining tests behave and changes no production code. ## CI - Both `dotnet test` steps pass `--filter "Category!=Manual"`. Before this, Manual-tagged tests ran on CI anyway. - The one surviving movement-throttle latency test is the only coverage of burst forgiveness over a full, wrapped history. It loses its Manual tag, so it runs on CI. ## Tests that passed on CI without testing anything - **Corpse and throwing tests.** They relied on tiledata for the weapon `Layer`, so on CI the equip silently failed and they asserted against empty lists. They now set `Layer` explicitly and assert the equip took effect. `TestThrown` also pins its own strength and range values, so a shard retuning SoulGlaive no longer breaks them. - **Healthbar poison rows.** Server.Tests registers no poisons, so every row tested `null`. They now use real poison levels. - **Account packet tests.** The mock accounts reported `Length` 0, so the character-list tests only ever encoded empty slots. They now encode the real characters. - **Pathing and AI tests that only mean something on real Trammel/Felucca terrain** are now guarded with `TileDataRequirement.SkipIfMissing()`: Britain desk and clutter scenes, house footprints (no MultiData on CI) and fingerprints. Tests that are valid on flat blank terrain stay unguarded. (A synthetic tiledata fixture to run these on CI is a planned follow-up.) - **Assertions that couldn't fail now check their claim.** Affected tests include the `DefaultWalker` cache use, cache on/off parity requiring a path, the recorder capability flags, the idle-pet gate, the monthly DST recurrence, the AdvancedSearch `Record.Exception` wrappers, `CanFitItem` with no branch-guarded assert, the Firewall callback, and `Import_NoMap`. The Geometry Parse asserts also now use the same input as their TryParse. ## Shared state Every test that changes process-wide state now restores it, even when an assert fails: - **The clock.** A new `TimerWheelScope` saves and restores `Core._tickCount`, `Core._now` and the timer wheel. `SimulatedClockScope` covers decay tests. - **StepCache settings and caches**, via `StepCacheStateScope`. - **Network state.** The ManualAllowlist, LoginAllowlist, firewall and BanChannel reporters are restored. Global packet handlers are now registered per test and removed afterwards, so they no longer stay registered for later tests. - **Data and config tables.** `ArchiveJournal` statics, `TileData.ItemTable`, `ObjectPropertyList.Enabled`, `Core.Expansion` and the localization table are restored. One `MobileStatusVersion` restore was resetting a different expansion than the one the test changed. - **Entities.** Tests with fixed serials now delete what they create. Fixed mobile serials moved to `World.NewMobile`, because deleting a hard-coded serial could unregister a live entity. - **Collection race.** `SpiralScanTests` no longer clears the spawn cache from a separate collection that could run in parallel with the cache-manager tests. - **Shared statics.** Classes reading shared static allowlists joined the sequential collection. ## Duplication New shared helpers replace copy-pasted harness code: - **Server.Tests:** `PacketAssert.Sends`, used by about 130 packet tests; `TestClientHarness`, `PersistencePipelineScope`, `NetTestHelpers`, `EntityCleanup` and one `TestMulti`. - **UOContent.Tests:** `TimerWheelScope`, which also holds one wraparound-safe `RunFor`/`RunUntil`; `AiTestStubs`, which merges six walker copies and five identical creature stubs; `MobileTestHarness`, `CommandTestHarness` and `TempDirectory`. Dead oracle packet classes are removed. ## Cost | Test | Before | After | |---|---|---| | `VirtualSerialTests` | 1.57s | 2ms (starts near the wrap via reflection instead of drawing ~17.9M serials) | | Event scheduler recurrence loop | 473ms | 1ms | | CrowdSec drain | 517ms | 16ms (event-driven instead of a fixed 500ms wait) | | AuthId tests | 248ms | 99ms (SHA2 except the two GameLogin tests) | | Container cap tests | 5,000 items | 3,449 / 3,277 (one past each protocol cap) | | Bulk removal | 100k children | 20k children | | OPL hash distribution | 60k builds | 10k builds | ## Shard-tuning decoupling - AI assertions read `ReacquireDelay` and `FollowMoveSpeed` instead of hard-coding production tuning. - The guard friendly-fire test uses an `AI_Mage` stub instead of WhiteWyrm. - Argon2 assertions pin the `argon2id` variant and `v=19` but read the cost parameters from the configured hasher. ## Tests | Run | Server.Tests | UOContent.Tests | |---|---|---| | With client files | 812 pass | 1,123 pass | | Without client files (CI simulation) | 800 pass, 12 skip | 1,021 pass, 102 skip | - The UOContent fixture reads `MODERNUO_TEST_DATA_DIR`; Server.Tests reads `MODERNUO_CLIENT_PATH`. - The 15 new UOContent skips are the map-dependent guards above. - Total run time with client files is about 5s, down from about 8s.
This commit is contained in:
parent
79f736aa83
commit
00134cac33
135 changed files with 3164 additions and 4020 deletions
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using Server.Accounting;
|
||||
using Server.Network;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -10,60 +8,6 @@ namespace Server.Tests.Network;
|
|||
[Collection("Sequential Server Tests")]
|
||||
public class AccountPacketTests
|
||||
{
|
||||
private class MockedAccount : IAccount
|
||||
{
|
||||
public int TotalGold { get; }
|
||||
public int TotalPlat { get; }
|
||||
public bool DepositGold(int amount) => throw new NotImplementedException();
|
||||
|
||||
public bool DepositPlat(int amount) => throw new NotImplementedException();
|
||||
|
||||
public bool WithdrawGold(int amount) => throw new NotImplementedException();
|
||||
|
||||
public bool WithdrawPlat(int amount) => throw new NotImplementedException();
|
||||
|
||||
public long GetTotalGold() => throw new NotImplementedException();
|
||||
|
||||
public int CompareTo(IAccount other) => throw new NotImplementedException();
|
||||
|
||||
public string Username { get; }
|
||||
public string Email { get; set; }
|
||||
public AccessLevel AccessLevel { get; set; }
|
||||
public int Length { get; }
|
||||
public int Limit { get; }
|
||||
public int Count { get; }
|
||||
|
||||
private Dictionary<int, Mobile> _mobiles = new();
|
||||
|
||||
public Mobile this[int index]
|
||||
{
|
||||
get => _mobiles[index];
|
||||
set
|
||||
{
|
||||
_mobiles[index] = value;
|
||||
if (value != null)
|
||||
{
|
||||
value.Account = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public Serial Serial { get; }
|
||||
public void Deserialize(IGenericReader reader) => throw new NotImplementedException();
|
||||
|
||||
public void Serialize(IGenericWriter writer) => throw new NotImplementedException();
|
||||
|
||||
public bool Deleted { get; }
|
||||
|
||||
public void Delete() => throw new NotImplementedException();
|
||||
public bool TrySetUsername(string username) => throw new NotImplementedException();
|
||||
|
||||
public void SetPassword(string password) => throw new NotImplementedException();
|
||||
|
||||
public bool CheckPassword(string password) => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestChangeCharacter()
|
||||
{
|
||||
|
|
@ -75,58 +19,38 @@ public class AccountPacketTests
|
|||
secondMobile.DefaultMobileInit();
|
||||
secondMobile.RawName = null;
|
||||
|
||||
var account = new MockedAccount
|
||||
var account = new MockAccount
|
||||
{
|
||||
[0] = firstMobile,
|
||||
[1] = null,
|
||||
[2] = secondMobile
|
||||
};
|
||||
|
||||
// var account = new MockAccount(new[] { firstMobile, null, secondMobile });
|
||||
var expected = new ChangeCharacter(account).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendChangeCharacter(account);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new ChangeCharacter(account), ns => ns.SendChangeCharacter(account));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestClientVersionReq()
|
||||
{
|
||||
var expected = new ClientVersionReq().Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
|
||||
ns.SendClientVersionRequest();
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new ClientVersionReq(), ns => ns.SendClientVersionRequest());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDeleteResult()
|
||||
{
|
||||
var expected = new DeleteResult(DeleteResultType.BadRequest).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendCharacterDeleteResult(DeleteResultType.BadRequest);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new DeleteResult(DeleteResultType.BadRequest),
|
||||
ns => ns.SendCharacterDeleteResult(DeleteResultType.BadRequest)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPopupMessage()
|
||||
{
|
||||
var expected = new PopupMessage(PMMessage.LoginSyncError).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendPopupMessage(PMMessage.LoginSyncError);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new PopupMessage(PMMessage.LoginSyncError),
|
||||
ns => ns.SendPopupMessage(PMMessage.LoginSyncError)
|
||||
);
|
||||
}
|
||||
|
||||
[Theory, InlineData(ProtocolChanges.Version70610), InlineData(ProtocolChanges.Version6000)]
|
||||
|
|
@ -136,7 +60,7 @@ public class AccountPacketTests
|
|||
firstMobile.DefaultMobileInit();
|
||||
firstMobile.Name = "Test Mobile";
|
||||
|
||||
var account = new MockedAccount
|
||||
var account = new MockAccount
|
||||
{
|
||||
[0] = firstMobile,
|
||||
[1] = null,
|
||||
|
|
@ -168,25 +92,13 @@ public class AccountPacketTests
|
|||
m.Direction = Direction.Down;
|
||||
m.LogoutMap = Map.Felucca;
|
||||
|
||||
var expected = new LoginConfirm(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendLoginConfirmation(m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new LoginConfirm(m), ns => ns.SendLoginConfirmation(m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestLoginComplete()
|
||||
{
|
||||
var expected = new LoginComplete().Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendLoginComplete();
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new LoginComplete(), ns => ns.SendLoginComplete());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -196,7 +108,7 @@ public class AccountPacketTests
|
|||
firstMobile.DefaultMobileInit();
|
||||
firstMobile.RawName = "Test Mobile";
|
||||
|
||||
var account = new MockedAccount
|
||||
var account = new MockAccount
|
||||
{
|
||||
[0] = null,
|
||||
[1] = firstMobile,
|
||||
|
|
@ -205,13 +117,7 @@ public class AccountPacketTests
|
|||
[4] = null
|
||||
};
|
||||
|
||||
var expected = new CharacterListUpdate(account).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendCharacterListUpdate(account);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new CharacterListUpdate(account), ns => ns.SendCharacterListUpdate(account));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -221,7 +127,7 @@ public class AccountPacketTests
|
|||
firstMobile.DefaultMobileInit();
|
||||
firstMobile.Name = "Test Mobile";
|
||||
|
||||
var account = new MockedAccount
|
||||
var account = new MockAccount
|
||||
{
|
||||
[0] = null,
|
||||
[1] = firstMobile,
|
||||
|
|
@ -235,17 +141,16 @@ public class AccountPacketTests
|
|||
new CityInfo("Test City", "Test Building", 50, 100, 10, -10)
|
||||
};
|
||||
|
||||
var expected = new CharacterList(account, info).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.CityInfo = info;
|
||||
ns.Account = account;
|
||||
ns.ProtocolChanges = ProtocolChanges.Version70130;
|
||||
|
||||
ns.SendCharacterList();
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new CharacterList(account, info),
|
||||
ns =>
|
||||
{
|
||||
ns.CityInfo = info;
|
||||
ns.Account = account;
|
||||
ns.SendCharacterList();
|
||||
},
|
||||
ProtocolChanges.Version70130
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -255,7 +160,7 @@ public class AccountPacketTests
|
|||
firstMobile.DefaultMobileInit();
|
||||
firstMobile.Name = "Test Mobile";
|
||||
|
||||
var account = new MockedAccount
|
||||
var account = new MockAccount
|
||||
{
|
||||
[0] = null,
|
||||
[1] = firstMobile,
|
||||
|
|
@ -269,29 +174,23 @@ public class AccountPacketTests
|
|||
new CityInfo("Test City", "Test Building", 50, 100, 10, -10)
|
||||
};
|
||||
|
||||
var expected = new CharacterListOld(account, info).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.CityInfo = info;
|
||||
ns.Account = account;
|
||||
|
||||
ns.SendCharacterList();
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new CharacterListOld(account, info),
|
||||
ns =>
|
||||
{
|
||||
ns.CityInfo = info;
|
||||
ns.Account = account;
|
||||
ns.SendCharacterList();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountLoginRej()
|
||||
{
|
||||
var reason = ALRReason.BadComm;
|
||||
var expected = new AccountLoginRej(reason).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendAccountLoginRejected(reason);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new AccountLoginRej(reason), ns => ns.SendAccountLoginRejected(reason));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -302,15 +201,14 @@ public class AccountPacketTests
|
|||
new ServerInfo("Test Server", 0, TimeZoneInfo.Local, IPEndPoint.Parse("127.0.0.1"))
|
||||
};
|
||||
|
||||
var expected = new AccountLoginAck(info).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ServerInfo = info;
|
||||
|
||||
ns.SendAccountLoginAck();
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new AccountLoginAck(info),
|
||||
ns =>
|
||||
{
|
||||
ns.ServerInfo = info;
|
||||
ns.SendAccountLoginAck();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -319,13 +217,6 @@ public class AccountPacketTests
|
|||
var si = new ServerInfo("Test Server", 0, TimeZoneInfo.Local, IPEndPoint.Parse("127.0.0.1"));
|
||||
const int authId = 0x123456;
|
||||
|
||||
var expected = new PlayServerAck(si, authId).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
|
||||
ns.SendPlayServerAck(si, authId);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new PlayServerAck(si, authId), ns => ns.SendPlayServerAck(si, authId));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,25 +12,13 @@ public class CombatPacketTests
|
|||
var attacker = (Serial)0x1024;
|
||||
var defender = (Serial)0x2048;
|
||||
|
||||
var expected = new Swing(attacker, defender).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendSwing(attacker, defender);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new Swing(attacker, defender), ns => ns.SendSwing(attacker, defender));
|
||||
}
|
||||
|
||||
[Theory, InlineData(true), InlineData(false)]
|
||||
public void TestSetWarMode(bool warmode)
|
||||
{
|
||||
var expected = new SetWarMode(warmode).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendSetWarMode(warmode);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new SetWarMode(warmode), ns => ns.SendSetWarMode(warmode));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -38,12 +26,6 @@ public class CombatPacketTests
|
|||
{
|
||||
var serial = (Serial)0x1024;
|
||||
|
||||
var expected = new ChangeCombatant(serial).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendChangeCombatant(serial);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new ChangeCombatant(serial), ns => ns.SendChangeCombatant(serial));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,13 +14,7 @@ public class ContainerPacketTests
|
|||
var serial = (Serial)0x1024;
|
||||
ushort gumpId = 100;
|
||||
|
||||
var expected = new ContainerDisplay(serial, gumpId).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplayContainer(serial, gumpId);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new ContainerDisplay(serial, gumpId), ns => ns.SendDisplayContainer(serial, gumpId));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -29,14 +23,11 @@ public class ContainerPacketTests
|
|||
var serial = (Serial)0x1024;
|
||||
ushort gumpId = 100;
|
||||
|
||||
var expected = new ContainerDisplayHS(serial, gumpId).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = ns.ProtocolChanges | ProtocolChanges.ContainerGridLines | ProtocolChanges.HighSeas;
|
||||
ns.SendDisplayContainer(serial, gumpId);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new ContainerDisplayHS(serial, gumpId),
|
||||
ns => ns.SendDisplayContainer(serial, gumpId),
|
||||
ProtocolChanges.ContainerGridLines | ProtocolChanges.HighSeas
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -44,13 +35,7 @@ public class ContainerPacketTests
|
|||
{
|
||||
var serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DisplaySpellbook(serial).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplaySpellbook(serial);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new DisplaySpellbook(serial), ns => ns.SendDisplaySpellbook(serial));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -58,14 +43,11 @@ public class ContainerPacketTests
|
|||
{
|
||||
var serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DisplaySpellbookHS(serial).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = ns.ProtocolChanges | ProtocolChanges.ContainerGridLines | ProtocolChanges.HighSeas;
|
||||
ns.SendDisplaySpellbook(serial);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new DisplaySpellbookHS(serial),
|
||||
ns => ns.SendDisplaySpellbook(serial),
|
||||
ProtocolChanges.ContainerGridLines | ProtocolChanges.HighSeas
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -76,17 +58,20 @@ public class ContainerPacketTests
|
|||
ushort offset = 10;
|
||||
ulong content = 0x123456789ABCDEF0;
|
||||
var opl = ObjectPropertyList.Enabled;
|
||||
|
||||
var expected = new NewSpellbookContent(serial, graphic, offset, content).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = ns.ProtocolChanges | ProtocolChanges.ContainerGridLines | ProtocolChanges.NewSpellbook;
|
||||
ObjectPropertyList.Enabled = true;
|
||||
ns.SendSpellbookContent(serial, graphic, offset, content);
|
||||
ObjectPropertyList.Enabled = opl;
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
try
|
||||
{
|
||||
PacketAssert.Sends(
|
||||
new NewSpellbookContent(serial, graphic, offset, content),
|
||||
ns => ns.SendSpellbookContent(serial, graphic, offset, content),
|
||||
ProtocolChanges.ContainerGridLines | ProtocolChanges.NewSpellbook
|
||||
);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ObjectPropertyList.Enabled = opl;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -97,13 +82,10 @@ public class ContainerPacketTests
|
|||
ushort graphic = 100;
|
||||
ulong content = 0x123456789ABCDEF0;
|
||||
|
||||
var expected = new SpellbookContent(serial, offset, content).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendSpellbookContent(serial, graphic, offset, content);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new SpellbookContent(serial, offset, content),
|
||||
ns => ns.SendSpellbookContent(serial, graphic, offset, content)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -114,14 +96,11 @@ public class ContainerPacketTests
|
|||
ushort graphic = 100;
|
||||
ulong content = 0x123456789ABCDEF0;
|
||||
|
||||
var expected = new SpellbookContent6017(serial, offset, content).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges |= ProtocolChanges.ContainerGridLines;
|
||||
ns.SendSpellbookContent(serial, graphic, offset, content);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new SpellbookContent6017(serial, offset, content),
|
||||
ns => ns.SendSpellbookContent(serial, graphic, offset, content),
|
||||
ProtocolChanges.ContainerGridLines
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -130,13 +109,7 @@ public class ContainerPacketTests
|
|||
var serial = (Serial)0x1024;
|
||||
var item = new Item(serial);
|
||||
|
||||
var expected = new ContainerContentUpdate(item).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendContainerContentUpdate(item);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new ContainerContentUpdate(item), ns => ns.SendContainerContentUpdate(item));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -145,66 +118,17 @@ public class ContainerPacketTests
|
|||
var serial = (Serial)0x1024;
|
||||
var item = new Item(serial);
|
||||
|
||||
var expected = new ContainerContentUpdate6017(item).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges |= ProtocolChanges.ContainerGridLines;
|
||||
ns.SendContainerContentUpdate(item);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new ContainerContentUpdate6017(item),
|
||||
ns => ns.SendContainerContentUpdate(item),
|
||||
ProtocolChanges.ContainerGridLines
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestContainerContent()
|
||||
// An administrator beholder on the container's map, so every item is visible and sent.
|
||||
private static (Container Container, Mobile Beholder) CreateViewedContainer(int itemCount)
|
||||
{
|
||||
var cont = new Container(World.NewItem);
|
||||
cont.AddItem(new Item(World.NewItem));
|
||||
cont.Map = Map.Felucca;
|
||||
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.AccessLevel = AccessLevel.Administrator;
|
||||
m.Map = Map.Felucca;
|
||||
|
||||
var expected = new ContainerContent(m, cont).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendContainerContent(m, cont);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestContainerContent6017()
|
||||
{
|
||||
var cont = new Container(World.NewItem);
|
||||
cont.AddItem(new Item(World.NewItem));
|
||||
cont.Map = Map.Felucca;
|
||||
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.AccessLevel = AccessLevel.Administrator;
|
||||
m.Map = Map.Felucca;
|
||||
|
||||
var expected = new ContainerContent6017(m, cont).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges |= ProtocolChanges.ContainerGridLines;
|
||||
ns.SendContainerContent(m, cont);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestContainerContent_CapsAtProtocolLimit()
|
||||
{
|
||||
var cont = new Container(World.NewItem);
|
||||
|
||||
// Past the 3448-entry cap (19-byte entries) so truncation engages.
|
||||
const int itemCount = 5000;
|
||||
for (var i = 0; i < itemCount; i++)
|
||||
{
|
||||
cont.AddItem(new Item(World.NewItem));
|
||||
|
|
@ -217,9 +141,62 @@ public class ContainerPacketTests
|
|||
m.AccessLevel = AccessLevel.Administrator;
|
||||
m.Map = Map.Felucca;
|
||||
|
||||
return (cont, m);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestContainerContent()
|
||||
{
|
||||
var (cont, m) = CreateViewedContainer(1);
|
||||
|
||||
try
|
||||
{
|
||||
PacketAssert.Sends(new ContainerContent(m, cont), ns => ns.SendContainerContent(m, cont));
|
||||
}
|
||||
finally
|
||||
{
|
||||
cont.Delete();
|
||||
m.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestContainerContent6017()
|
||||
{
|
||||
var (cont, m) = CreateViewedContainer(1);
|
||||
|
||||
try
|
||||
{
|
||||
PacketAssert.Sends(
|
||||
new ContainerContent6017(m, cont),
|
||||
ns => ns.SendContainerContent(m, cont),
|
||||
ProtocolChanges.ContainerGridLines
|
||||
);
|
||||
}
|
||||
finally
|
||||
{
|
||||
cont.Delete();
|
||||
m.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
// 0x3C's length and count fields are 16-bit: 19-byte entries cap at 3448, 20-byte grid-line entries at 3276.
|
||||
[Theory]
|
||||
[InlineData(false, 3448, 65517)]
|
||||
[InlineData(true, 3276, 65525)]
|
||||
public void TestContainerContent_CapsAtProtocolLimit(bool gridLines, int maxEntries, int maxLength)
|
||||
{
|
||||
// One item past the cap is enough to make truncation engage.
|
||||
var (cont, m) = CreateViewedContainer(maxEntries + 1);
|
||||
|
||||
try
|
||||
{
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
if (gridLines)
|
||||
{
|
||||
ns.ProtocolChanges |= ProtocolChanges.ContainerGridLines;
|
||||
}
|
||||
|
||||
// A ~64KB packet exceeds the 4KB pre-auth send buffer; an account lets Send() promote it
|
||||
// on demand instead of exhausting the buffer and disconnecting.
|
||||
ns.Account = new MockAccount();
|
||||
|
|
@ -233,57 +210,9 @@ public class ContainerPacketTests
|
|||
var length = BinaryPrimitives.ReadUInt16BigEndian(span[1..3]);
|
||||
var count = BinaryPrimitives.ReadUInt16BigEndian(span[3..5]);
|
||||
|
||||
const int entrySize = 19; // no grid lines negotiated on this NetState
|
||||
var expectedMaxEntries = (ushort.MaxValue - 5) / entrySize;
|
||||
|
||||
Assert.Equal(65517, length);
|
||||
Assert.Equal(maxLength, length);
|
||||
Assert.Equal(length, span.Length);
|
||||
Assert.Equal(expectedMaxEntries, count);
|
||||
}
|
||||
finally
|
||||
{
|
||||
cont.Delete();
|
||||
m.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestContainerContent_CapsAtProtocolLimit_WithGridLines()
|
||||
{
|
||||
var cont = new Container(World.NewItem);
|
||||
|
||||
// Past the 3276-entry cap (20-byte entries with grid lines) so truncation engages.
|
||||
const int itemCount = 5000;
|
||||
for (var i = 0; i < itemCount; i++)
|
||||
{
|
||||
cont.AddItem(new Item(World.NewItem));
|
||||
}
|
||||
|
||||
cont.Map = Map.Felucca;
|
||||
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.AccessLevel = AccessLevel.Administrator;
|
||||
m.Map = Map.Felucca;
|
||||
|
||||
try
|
||||
{
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges |= ProtocolChanges.ContainerGridLines;
|
||||
ns.Account = new MockAccount();
|
||||
|
||||
var ex = Record.Exception(() => ns.SendContainerContent(m, cont));
|
||||
Assert.Null(ex);
|
||||
|
||||
var span = ns.SendBuffer.GetReadSpan();
|
||||
Assert.Equal((byte)0x3C, span[0]);
|
||||
|
||||
var length = BinaryPrimitives.ReadUInt16BigEndian(span[1..3]);
|
||||
var count = BinaryPrimitives.ReadUInt16BigEndian(span[3..5]);
|
||||
|
||||
Assert.Equal(65525, length);
|
||||
Assert.Equal(length, span.Length);
|
||||
Assert.Equal(3276, count);
|
||||
Assert.Equal(maxEntries, count);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -295,32 +224,13 @@ public class ContainerPacketTests
|
|||
[Fact]
|
||||
public void TestContainerContent_RentedBuffer_MatchesReferencePacket()
|
||||
{
|
||||
var cont = new Container(World.NewItem);
|
||||
|
||||
// Below the entry cap but past the 1024-byte stackalloc threshold, so SendContainerContent
|
||||
// rents its buffer instead of using the stack.
|
||||
const int itemCount = 100;
|
||||
for (var i = 0; i < itemCount; i++)
|
||||
{
|
||||
cont.AddItem(new Item(World.NewItem));
|
||||
}
|
||||
|
||||
cont.Map = Map.Felucca;
|
||||
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.AccessLevel = AccessLevel.Administrator;
|
||||
m.Map = Map.Felucca;
|
||||
var (cont, m) = CreateViewedContainer(100);
|
||||
|
||||
try
|
||||
{
|
||||
var expected = new ContainerContent(m, cont).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendContainerContent(m, cont);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new ContainerContent(m, cont), ns => ns.SendContainerContent(m, cont));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,13 +11,7 @@ public class DamagePacketTests
|
|||
{
|
||||
var serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DamagePacketOld(serial, inputAmount).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDamage(serial, inputAmount);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new DamagePacketOld(serial, inputAmount), ns => ns.SendDamage(serial, inputAmount));
|
||||
}
|
||||
|
||||
[Theory, InlineData(10), InlineData(-5), InlineData(1024), InlineData(100000)]
|
||||
|
|
@ -25,14 +19,10 @@ public class DamagePacketTests
|
|||
{
|
||||
var serial = (Serial)0x1024;
|
||||
|
||||
var expected = new DamagePacket(serial, inputAmount).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = ProtocolChanges.DamagePacket;
|
||||
|
||||
ns.SendDamage(serial, inputAmount);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new DamagePacket(serial, inputAmount),
|
||||
ns => ns.SendDamage(serial, inputAmount),
|
||||
ProtocolChanges.DamagePacket
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,18 +7,13 @@ namespace Server.Tests.Network;
|
|||
[Collection("Sequential Server Tests")]
|
||||
public class EffectPackets
|
||||
{
|
||||
[Theory, InlineData(10, 1000, 10, 5)]
|
||||
public void TestSoundEffect(ushort soundID, int x, int y, int z)
|
||||
[Fact]
|
||||
public void TestSoundEffect()
|
||||
{
|
||||
var p = new Point3D(x, y, z);
|
||||
const ushort soundID = 10;
|
||||
var p = new Point3D(1000, 10, 5);
|
||||
|
||||
var expected = new PlaySound(soundID, p).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendSoundEffect(soundID, p);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new PlaySound(soundID, p), ns => ns.SendSoundEffect(soundID, p));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -94,13 +89,7 @@ public class EffectPackets
|
|||
[Theory, InlineData(ScreenEffectType.DarkFlash), InlineData(ScreenEffectType.FadeInOut)]
|
||||
public void TestScreenEffect(ScreenEffectType screenType)
|
||||
{
|
||||
var expected = new ScreenEffect(screenType).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendScreenEffect(screenType);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new ScreenEffect(screenType), ns => ns.SendScreenEffect(screenType));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -76,157 +76,6 @@ public class HuedEffect : Packet
|
|||
}
|
||||
}
|
||||
|
||||
public sealed class TargetParticleEffect : ParticleEffect
|
||||
{
|
||||
public TargetParticleEffect(
|
||||
IEntity e, int itemID, int speed, int duration, int hue, int renderMode, int effect,
|
||||
int layer, int unknown
|
||||
) : base(
|
||||
EffectType.FixedFrom,
|
||||
e.Serial,
|
||||
Serial.Zero,
|
||||
itemID,
|
||||
e.Location,
|
||||
e.Location,
|
||||
speed,
|
||||
duration,
|
||||
true,
|
||||
false,
|
||||
hue,
|
||||
renderMode,
|
||||
effect,
|
||||
1,
|
||||
0,
|
||||
e.Serial,
|
||||
layer,
|
||||
unknown
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TargetEffect : HuedEffect
|
||||
{
|
||||
public TargetEffect(IEntity e, int itemID, int speed, int duration, int hue, int renderMode) : base(
|
||||
EffectType.FixedFrom,
|
||||
e.Serial,
|
||||
Serial.Zero,
|
||||
itemID,
|
||||
e.Location,
|
||||
e.Location,
|
||||
speed,
|
||||
duration,
|
||||
true,
|
||||
false,
|
||||
hue,
|
||||
renderMode
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class LocationParticleEffect : ParticleEffect
|
||||
{
|
||||
public LocationParticleEffect(
|
||||
IEntity e, int itemID, int speed, int duration, int hue, int renderMode, int effect,
|
||||
int unknown
|
||||
) : base(
|
||||
EffectType.FixedXYZ,
|
||||
e.Serial,
|
||||
Serial.Zero,
|
||||
itemID,
|
||||
e.Location,
|
||||
e.Location,
|
||||
speed,
|
||||
duration,
|
||||
true,
|
||||
false,
|
||||
hue,
|
||||
renderMode,
|
||||
effect,
|
||||
1,
|
||||
0,
|
||||
e.Serial,
|
||||
255,
|
||||
unknown
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class LocationEffect : HuedEffect
|
||||
{
|
||||
public LocationEffect(IPoint3D p, int itemID, int speed, int duration, int hue, int renderMode) : base(
|
||||
EffectType.FixedXYZ,
|
||||
Serial.Zero,
|
||||
Serial.Zero,
|
||||
itemID,
|
||||
p,
|
||||
p,
|
||||
speed,
|
||||
duration,
|
||||
true,
|
||||
false,
|
||||
hue,
|
||||
renderMode
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MovingParticleEffect : ParticleEffect
|
||||
{
|
||||
public MovingParticleEffect(
|
||||
IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection,
|
||||
bool explodes, int hue, int renderMode, int effect, int explodeEffect, int explodeSound, EffectLayer layer,
|
||||
int unknown
|
||||
) : base(
|
||||
EffectType.Moving,
|
||||
from.Serial,
|
||||
to.Serial,
|
||||
itemID,
|
||||
from.Location,
|
||||
to.Location,
|
||||
speed,
|
||||
duration,
|
||||
fixedDirection,
|
||||
explodes,
|
||||
hue,
|
||||
renderMode,
|
||||
effect,
|
||||
explodeEffect,
|
||||
explodeSound,
|
||||
Serial.Zero,
|
||||
(int)layer,
|
||||
unknown
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MovingEffect : HuedEffect
|
||||
{
|
||||
public MovingEffect(
|
||||
IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection,
|
||||
bool explodes, int hue, int renderMode
|
||||
) : base(
|
||||
EffectType.Moving,
|
||||
from.Serial,
|
||||
to.Serial,
|
||||
itemID,
|
||||
from.Location,
|
||||
to.Location,
|
||||
speed,
|
||||
duration,
|
||||
fixedDirection,
|
||||
explodes,
|
||||
hue,
|
||||
renderMode
|
||||
)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class ScreenEffect : Packet
|
||||
{
|
||||
public ScreenEffect(ScreenEffectType type)
|
||||
|
|
|
|||
|
|
@ -31,19 +31,16 @@ public class EquipmentPacketTests
|
|||
}
|
||||
);
|
||||
|
||||
var expected = new DisplayEquipmentInfo(item, info).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplayEquipmentInfo(
|
||||
item.Serial,
|
||||
info.Number,
|
||||
info.Crafter?.RawName,
|
||||
info.Unidentified,
|
||||
new List<EquipInfoAttribute>(info.Attributes)
|
||||
PacketAssert.Sends(
|
||||
new DisplayEquipmentInfo(item, info),
|
||||
ns => ns.SendDisplayEquipmentInfo(
|
||||
item.Serial,
|
||||
info.Number,
|
||||
info.Crafter?.RawName,
|
||||
info.Unidentified,
|
||||
new List<EquipInfoAttribute>(info.Attributes)
|
||||
)
|
||||
);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -54,12 +51,6 @@ public class EquipmentPacketTests
|
|||
|
||||
var item = new Item(World.NewItem) { Parent = m };
|
||||
|
||||
var expected = new EquipUpdate(item).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendEquipUpdate(item);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new EquipUpdate(item), ns => ns.SendEquipUpdate(item));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,17 +6,13 @@ namespace Server.Tests.Network;
|
|||
[Collection("Sequential Server Tests")]
|
||||
public class GumpPacketTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(100, 10)]
|
||||
public void TestCloseGump(int typeId, int buttonId)
|
||||
[Fact]
|
||||
public void TestCloseGump()
|
||||
{
|
||||
var expected = new CloseGump(typeId, buttonId).Compile();
|
||||
const int typeId = 100;
|
||||
const int buttonId = 10;
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendCloseGump(typeId, buttonId);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new CloseGump(typeId, buttonId), ns => ns.SendCloseGump(typeId, buttonId));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -27,13 +23,10 @@ public class GumpPacketTests
|
|||
const string unknownString = "This is an unknown string";
|
||||
const string caption = "This is a caption";
|
||||
|
||||
var expected = new DisplaySignGump(gumpSerial, gumpId, unknownString, caption).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplaySignGump(gumpSerial, gumpId, unknownString, caption);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new DisplaySignGump(gumpSerial, gumpId, unknownString, caption),
|
||||
ns => ns.SendDisplaySignGump(gumpSerial, gumpId, unknownString, caption)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -41,13 +34,7 @@ public class GumpPacketTests
|
|||
{
|
||||
var gump = new NameChangeDeedGump();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
|
||||
var expected = gump.Compile(ns).Compile();
|
||||
ns.SendGump(gump);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(ns => gump.Compile(ns), ns => ns.SendGump(gump));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -60,13 +47,7 @@ public class GumpPacketTests
|
|||
|
||||
var gump = new AdminGump(m, AdminGumpPage.Clients);
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
|
||||
var expected = gump.Compile(ns).Compile();
|
||||
ns.SendGump(gump);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(ns => gump.Compile(ns), ns => ns.SendGump(gump));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,116 +1,75 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
using Xunit;
|
||||
|
||||
namespace Server.Tests.Network;
|
||||
|
||||
[Collection("Sequential Server Tests")]
|
||||
public class ItemPacketTests
|
||||
public class ItemPacketTests : IDisposable
|
||||
{
|
||||
private const int TestItemId = 1;
|
||||
|
||||
// TileData is global and holds real client data when client files are loaded, so each test restores it.
|
||||
private readonly ItemData _originalItemData;
|
||||
|
||||
public ItemPacketTests()
|
||||
{
|
||||
_originalItemData = TileData.ItemTable[TestItemId];
|
||||
TileData.ItemTable[TestItemId] = new ItemData("Test Item Data", TileFlag.Generic, 1, 1, 1, 1, 1, 1);
|
||||
}
|
||||
|
||||
public void Dispose() => TileData.ItemTable[TestItemId] = _originalItemData;
|
||||
|
||||
[Fact]
|
||||
public void TestWorldItemPacket()
|
||||
{
|
||||
var serial = (Serial)0x1024;
|
||||
var itemId = 1;
|
||||
|
||||
// Move to fixture
|
||||
TileData.ItemTable[itemId] = new ItemData(
|
||||
"Test Item Data",
|
||||
TileFlag.Generic,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
);
|
||||
|
||||
var item = new Item(serial)
|
||||
{
|
||||
ItemID = itemId,
|
||||
ItemID = TestItemId,
|
||||
Hue = 0x1024,
|
||||
Amount = 10,
|
||||
Location = new Point3D(1000, 100, -10),
|
||||
Direction = Direction.Left
|
||||
};
|
||||
|
||||
var expected = new WorldItem(item).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendWorldItem(item);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new WorldItem(item), ns => ns.SendWorldItem(item));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestWorldItemSAPacket()
|
||||
{
|
||||
var serial = (Serial)0x1024;
|
||||
ushort itemId = 1;
|
||||
|
||||
// Move to fixture
|
||||
TileData.ItemTable[itemId] = new ItemData(
|
||||
"Test Item Data",
|
||||
TileFlag.Generic,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
);
|
||||
|
||||
var item = new Item(serial)
|
||||
{
|
||||
ItemID = itemId,
|
||||
ItemID = TestItemId,
|
||||
Hue = 0x1024,
|
||||
Amount = 10,
|
||||
Location = new Point3D(1000, 100, -10)
|
||||
};
|
||||
|
||||
var expected = new WorldItemSA(item).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = ProtocolChanges.StygianAbyss;
|
||||
ns.SendWorldItem(item);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new WorldItemSA(item), ns => ns.SendWorldItem(item), ProtocolChanges.StygianAbyss);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestWorldItemHSPacket()
|
||||
{
|
||||
var serial = (Serial)0x1024;
|
||||
var itemId = 1;
|
||||
|
||||
// Move to fixture
|
||||
TileData.ItemTable[itemId] = new ItemData(
|
||||
"Test Item Data",
|
||||
TileFlag.Generic,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
);
|
||||
|
||||
var item = new Item(serial)
|
||||
{
|
||||
ItemID = itemId,
|
||||
ItemID = TestItemId,
|
||||
Hue = 0x1024,
|
||||
Amount = 10,
|
||||
Location = new Point3D(1000, 100, -10)
|
||||
};
|
||||
|
||||
var expected = new WorldItemHS(item).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = ProtocolChanges.StygianAbyss | ProtocolChanges.HighSeas;
|
||||
ns.SendWorldItem(item);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new WorldItemHS(item),
|
||||
ns => ns.SendWorldItem(item),
|
||||
ProtocolChanges.StygianAbyss | ProtocolChanges.HighSeas
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,21 +187,3 @@ public sealed class WorldItemHS : Packet
|
|||
Stream.Write((short)0x00); // ??
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class OPLInfo : Packet
|
||||
{
|
||||
/*public OPLInfo( ObjectPropertyList list ) : base( 0xBF )
|
||||
{
|
||||
EnsureCapacity( 13 );
|
||||
|
||||
m_Stream.Write( (short) 0x10 );
|
||||
m_Stream.Write( (int) list.Entity.Serial );
|
||||
m_Stream.Write( (int) list.Hash );
|
||||
}*/
|
||||
|
||||
public OPLInfo(Serial serial, int hash) : base(0xDC, 9)
|
||||
{
|
||||
Stream.Write(serial);
|
||||
Stream.Write(hash);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,13 +10,8 @@ public class LightPacketTests
|
|||
public void TestGlobalLightLevel()
|
||||
{
|
||||
const byte lightLevel = 5;
|
||||
var expected = new GlobalLightLevel(lightLevel).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendGlobalLightLevel(lightLevel);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new GlobalLightLevel(lightLevel), ns => ns.SendGlobalLightLevel(lightLevel));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -24,12 +19,10 @@ public class LightPacketTests
|
|||
{
|
||||
var serial = (Serial)0x1024;
|
||||
byte lightLevel = 5;
|
||||
var expected = new PersonalLightLevel(serial, lightLevel).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendPersonalLightLevel(serial, lightLevel);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new PersonalLightLevel(serial, lightLevel),
|
||||
ns => ns.SendPersonalLightLevel(serial, lightLevel)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,26 +9,13 @@ public class MapPatchesTests
|
|||
[Fact]
|
||||
public void TestMapPatches()
|
||||
{
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
|
||||
var expected = new MapPatches().Compile();
|
||||
|
||||
ns.SendMapPatches();
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MapPatches(), ns => ns.SendMapPatches());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestInvalidMapEnable()
|
||||
{
|
||||
var expected = new InvalidMapEnable().Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendInvalidMap();
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new InvalidMapEnable(), ns => ns.SendInvalidMap());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -37,12 +24,7 @@ public class MapPatchesTests
|
|||
public void TestMapChange(string mapName)
|
||||
{
|
||||
var map = Map.Parse(mapName);
|
||||
var expected = new MapChange(map).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMapChange(map);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MapChange(map), ns => ns.SendMapChange(map));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,13 +42,7 @@ public class MenuPacketTests
|
|||
]
|
||||
);
|
||||
|
||||
var expected = new DisplayItemListMenu(menu).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplayItemListMenu(menu);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new DisplayItemListMenu(menu), ns => ns.SendDisplayItemListMenu(menu));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -63,12 +57,7 @@ public class MenuPacketTests
|
|||
]
|
||||
);
|
||||
|
||||
var expected = new DisplayQuestionMenu(menu).Compile();
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplayQuestionMenu(menu);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new DisplayQuestionMenu(menu), ns => ns.SendDisplayQuestionMenu(menu));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -84,18 +73,12 @@ public class MenuPacketTests
|
|||
var item = new ContextMenuItem(World.NewItem, newPacket);
|
||||
var menu = ContextMenuSystem.CreateContextMenu(m, item);
|
||||
|
||||
var packet = newHaven && newPacket ? (Packet)new DisplayContextMenu(menu) : new DisplayContextMenuOld(menu);
|
||||
var expected = packet.Compile();
|
||||
var expected = newHaven && newPacket ? (Packet)new DisplayContextMenu(menu) : new DisplayContextMenuOld(menu);
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
if (newHaven)
|
||||
{
|
||||
ns.ProtocolChanges |= ProtocolChanges.NewHaven;
|
||||
}
|
||||
|
||||
ns.SendDisplayContextMenu(menu);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
expected,
|
||||
ns => ns.SendDisplayContextMenu(menu),
|
||||
newHaven ? ProtocolChanges.NewHaven : ProtocolChanges.None
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,31 +19,10 @@ public class MessageTests
|
|||
var name = "Stuff";
|
||||
var args = "Arguments";
|
||||
|
||||
var expected = new MessageLocalized(
|
||||
serial,
|
||||
graphic,
|
||||
messageType,
|
||||
hue,
|
||||
font,
|
||||
number,
|
||||
name,
|
||||
args
|
||||
).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMessageLocalized(
|
||||
serial,
|
||||
graphic,
|
||||
messageType,
|
||||
hue,
|
||||
font,
|
||||
number,
|
||||
name,
|
||||
args
|
||||
PacketAssert.Sends(
|
||||
new MessageLocalized(serial, graphic, messageType, hue, font, number, name, args),
|
||||
ns => ns.SendMessageLocalized(serial, graphic, messageType, hue, font, number, name, args)
|
||||
);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -58,15 +37,10 @@ public class MessageTests
|
|||
var name = "Stuff";
|
||||
var argValue = 42;
|
||||
|
||||
var expected = new MessageLocalized(
|
||||
serial, graphic, messageType, hue, font, number, name, $"value: {argValue}"
|
||||
).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMessageLocalized(serial, graphic, messageType, hue, font, number, name, $"value: {argValue}");
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new MessageLocalized(serial, graphic, messageType, hue, font, number, name, $"value: {argValue}"),
|
||||
ns => ns.SendMessageLocalized(serial, graphic, messageType, hue, font, number, name, $"value: {argValue}")
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -83,35 +57,12 @@ public class MessageTests
|
|||
var affixType = AffixType.System;
|
||||
var affix = "Affix";
|
||||
|
||||
var expected = new MessageLocalizedAffix(
|
||||
serial,
|
||||
graphic,
|
||||
messageType,
|
||||
hue,
|
||||
font,
|
||||
number,
|
||||
name,
|
||||
affixType,
|
||||
affix,
|
||||
args
|
||||
).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMessageLocalizedAffix(
|
||||
serial,
|
||||
graphic,
|
||||
messageType,
|
||||
hue,
|
||||
font,
|
||||
number,
|
||||
name,
|
||||
affixType,
|
||||
affix,
|
||||
args
|
||||
PacketAssert.Sends(
|
||||
new MessageLocalizedAffix(serial, graphic, messageType, hue, font, number, name, affixType, affix, args),
|
||||
ns => ns.SendMessageLocalizedAffix(
|
||||
serial, graphic, messageType, hue, font, number, name, affixType, affix, args
|
||||
)
|
||||
);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -128,18 +79,14 @@ public class MessageTests
|
|||
var affix = "Affix";
|
||||
var argValue = 42;
|
||||
|
||||
var expected = new MessageLocalizedAffix(
|
||||
serial, graphic, messageType, hue, font, number, name, affixType, affix, $"value: {argValue}"
|
||||
).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMessageLocalizedAffix(
|
||||
serial, graphic, messageType, hue, font, number, name, affixType, affix,
|
||||
$"value: {argValue}"
|
||||
PacketAssert.Sends(
|
||||
new MessageLocalizedAffix(
|
||||
serial, graphic, messageType, hue, font, number, name, affixType, affix, $"value: {argValue}"
|
||||
),
|
||||
ns => ns.SendMessageLocalizedAffix(
|
||||
serial, graphic, messageType, hue, font, number, name, affixType, affix, $"value: {argValue}"
|
||||
)
|
||||
);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -154,17 +101,10 @@ public class MessageTests
|
|||
var name = "Stuff";
|
||||
var who = "Alice";
|
||||
|
||||
var expected = new UnicodeMessage(
|
||||
serial, graphic, messageType, hue, font, lang, name, $"hello, {who}"
|
||||
).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMessage(
|
||||
serial, graphic, messageType, hue, font, false, lang, name, $"hello, {who}"
|
||||
PacketAssert.Sends(
|
||||
new UnicodeMessage(serial, graphic, messageType, hue, font, lang, name, $"hello, {who}"),
|
||||
ns => ns.SendMessage(serial, graphic, messageType, hue, font, false, lang, name, $"hello, {who}")
|
||||
);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -178,31 +118,10 @@ public class MessageTests
|
|||
var name = "Stuff";
|
||||
var text = "Some Text";
|
||||
|
||||
var expected = new AsciiMessage(
|
||||
serial,
|
||||
graphic,
|
||||
messageType,
|
||||
hue,
|
||||
font,
|
||||
name,
|
||||
text
|
||||
).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMessage(
|
||||
serial,
|
||||
graphic,
|
||||
messageType,
|
||||
hue,
|
||||
font,
|
||||
true,
|
||||
null,
|
||||
name,
|
||||
text
|
||||
PacketAssert.Sends(
|
||||
new AsciiMessage(serial, graphic, messageType, hue, font, name, text),
|
||||
ns => ns.SendMessage(serial, graphic, messageType, hue, font, true, null, name, text)
|
||||
);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -217,32 +136,10 @@ public class MessageTests
|
|||
var name = "Stuff";
|
||||
var text = "Some Text";
|
||||
|
||||
var expected = new UnicodeMessage(
|
||||
serial,
|
||||
graphic,
|
||||
messageType,
|
||||
hue,
|
||||
font,
|
||||
lang,
|
||||
name,
|
||||
text
|
||||
).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMessage(
|
||||
serial,
|
||||
graphic,
|
||||
messageType,
|
||||
hue,
|
||||
font,
|
||||
false,
|
||||
lang,
|
||||
name,
|
||||
text
|
||||
PacketAssert.Sends(
|
||||
new UnicodeMessage(serial, graphic, messageType, hue, font, lang, name, text),
|
||||
ns => ns.SendMessage(serial, graphic, messageType, hue, font, false, lang, name, text)
|
||||
);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -251,13 +148,7 @@ public class MessageTests
|
|||
var serial = (Serial)0x1024;
|
||||
var serial2 = (Serial)0x2;
|
||||
|
||||
var expected = new FollowMessage(serial, serial2).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendFollowMessage(serial, serial2);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new FollowMessage(serial, serial2), ns => ns.SendFollowMessage(serial, serial2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -266,33 +157,18 @@ public class MessageTests
|
|||
var s = (Serial)0x100;
|
||||
var text = "This is some testing text";
|
||||
|
||||
var expected = new ObjectHelpResponse(s, text).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendHelpResponse(s, text);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new ObjectHelpResponse(s, text), ns => ns.SendHelpResponse(s, text));
|
||||
}
|
||||
|
||||
internal class TestPrompt : Prompt
|
||||
[Fact]
|
||||
public void TestUnicodePrompt()
|
||||
{
|
||||
var prompt = new TestPrompt();
|
||||
|
||||
PacketAssert.Sends(new UnicodePrompt(prompt), ns => ns.SendPrompt(prompt));
|
||||
}
|
||||
|
||||
[Collection("Sequential Server Tests")]
|
||||
public class UnicodePromptTests
|
||||
private class TestPrompt : Prompt
|
||||
{
|
||||
[Fact]
|
||||
public void TestUnicodePrompt()
|
||||
{
|
||||
var prompt = new TestPrompt();
|
||||
var expected = new UnicodePrompt(prompt).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendPrompt(prompt);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,38 @@ namespace Server.Tests.Network;
|
|||
[Collection("Sequential Server Tests")]
|
||||
public class MobilePacketTests
|
||||
{
|
||||
private static Mobile CreateMobileWithStats(uint serial = 0x1, string name = null)
|
||||
{
|
||||
var m = new Mobile((Serial)serial) { Name = name };
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 50;
|
||||
m.Hits = 100;
|
||||
m.Int = 75;
|
||||
m.Mana = 100;
|
||||
m.Dex = 25;
|
||||
m.Stam = 100;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
private sealed class TestPoison : Poison
|
||||
{
|
||||
public TestPoison(int level) : base(level) => Level = level;
|
||||
|
||||
public override string Name => $"Test Poison {Level}";
|
||||
public override int Level { get; }
|
||||
public override PoisonFamily Family => PoisonFamily.Standard;
|
||||
|
||||
public override Timer ConstructTimer(Mobile m) => null;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDeathAnimation()
|
||||
{
|
||||
var killed = (Serial)0x1;
|
||||
var corpse = (Serial)0x1000;
|
||||
|
||||
var expected = new DeathAnimation(killed, corpse).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDeathAnimation(killed, corpse);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new DeathAnimation(killed, corpse), ns => ns.SendDeathAnimation(killed, corpse));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -27,13 +46,7 @@ public class MobilePacketTests
|
|||
var petSerial = (Serial)0x1;
|
||||
const bool bonded = true;
|
||||
|
||||
var expected = new BondedStatus(petSerial, bonded).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendBondedStatus(petSerial, bonded);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new BondedStatus(petSerial, bonded), ns => ns.SendBondedStatus(petSerial, bonded));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -46,14 +59,11 @@ public class MobilePacketTests
|
|||
|
||||
var noto = 10;
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = protocolChanges;
|
||||
var expected = new MobileMoving(m, noto, ns.StygianAbyss).Compile();
|
||||
|
||||
ns.SendMobileMoving(m, noto);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
ns => new MobileMoving(m, noto, ns.StygianAbyss),
|
||||
ns => ns.SendMobileMoving(m, noto),
|
||||
protocolChanges
|
||||
);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -65,13 +75,7 @@ public class MobilePacketTests
|
|||
var m = new Mobile((Serial)0x1) { Name = name };
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var expected = new MobileName(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileName(m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MobileName(m), ns => ns.SendMobileName(m));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -81,29 +85,10 @@ public class MobilePacketTests
|
|||
{
|
||||
var mobile = (Serial)0x1;
|
||||
|
||||
var expected = new MobileAnimation(
|
||||
mobile,
|
||||
action,
|
||||
frameCount,
|
||||
repeatCount,
|
||||
!reverse,
|
||||
repeat,
|
||||
delay
|
||||
).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileAnimation(
|
||||
mobile,
|
||||
action,
|
||||
frameCount,
|
||||
repeatCount,
|
||||
!reverse,
|
||||
repeat,
|
||||
delay
|
||||
PacketAssert.Sends(
|
||||
new MobileAnimation(mobile, action, frameCount, repeatCount, !reverse, repeat, delay),
|
||||
ns => ns.SendMobileAnimation(mobile, action, frameCount, repeatCount, !reverse, repeat, delay)
|
||||
);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -113,43 +98,24 @@ public class MobilePacketTests
|
|||
{
|
||||
var mobile = (Serial)0x1;
|
||||
|
||||
var expected = new NewMobileAnimation(
|
||||
mobile,
|
||||
action,
|
||||
frameCount,
|
||||
delay
|
||||
).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendNewMobileAnimation(
|
||||
mobile,
|
||||
action,
|
||||
frameCount,
|
||||
delay
|
||||
PacketAssert.Sends(
|
||||
new NewMobileAnimation(mobile, action, frameCount, delay),
|
||||
ns => ns.SendNewMobileAnimation(mobile, action, frameCount, delay)
|
||||
);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
// Level -1 means not poisoned. Constructed directly: the poison registry is filled by UOContent.
|
||||
[Theory]
|
||||
[InlineData("None")]
|
||||
[InlineData("Lesser")]
|
||||
[InlineData("Lethal")]
|
||||
public void TestHealthbarPoison(string pName)
|
||||
[InlineData(-1)]
|
||||
[InlineData(0)]
|
||||
[InlineData(4)]
|
||||
public void TestHealthbarPoison(int level)
|
||||
{
|
||||
var p = Poison.GetPoison(pName);
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Poison = p;
|
||||
m.Poison = level < 0 ? null : new TestPoison(level);
|
||||
|
||||
var expected = new HealthbarPoison(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileHealthbar(m, Healthbar.Poison);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new HealthbarPoison(m), ns => ns.SendMobileHealthbar(m, Healthbar.Poison));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -164,13 +130,7 @@ public class MobilePacketTests
|
|||
m.Blessed = isBlessed;
|
||||
m.YellowHealthbar = isYellowHealth;
|
||||
|
||||
var expected = new HealthbarYellow(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileHealthbar(m, Healthbar.Yellow);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new HealthbarYellow(m), ns => ns.SendMobileHealthbar(m, Healthbar.Yellow));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -178,22 +138,9 @@ public class MobilePacketTests
|
|||
[InlineData(false)]
|
||||
public void TestMobileStatusCompact(bool canBeRenamed)
|
||||
{
|
||||
var m = new Mobile((Serial)0x1) { Name = "Random Mobile 1" };
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 50;
|
||||
m.Hits = 100;
|
||||
m.Int = 75;
|
||||
m.Mana = 100;
|
||||
m.Dex = 25;
|
||||
m.Stam = 100;
|
||||
var m = CreateMobileWithStats(name: "Random Mobile 1");
|
||||
|
||||
var expected = new MobileStatusCompact(canBeRenamed, m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileStatusCompact(m, canBeRenamed);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MobileStatusCompact(canBeRenamed, m), ns => ns.SendMobileStatusCompact(m, canBeRenamed));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -201,32 +148,14 @@ public class MobilePacketTests
|
|||
[InlineData(ProtocolChanges.Version502b)]
|
||||
public void TestMobileStatus(ProtocolChanges changes)
|
||||
{
|
||||
var beholder = new Mobile((Serial)0x1) { Name = "Random Mobile 1" };
|
||||
beholder.DefaultMobileInit();
|
||||
beholder.Str = 50;
|
||||
beholder.Hits = 100;
|
||||
beholder.Int = 75;
|
||||
beholder.Mana = 100;
|
||||
beholder.Dex = 25;
|
||||
beholder.Stam = 100;
|
||||
var beholder = CreateMobileWithStats(0x1, "Random Mobile 1");
|
||||
var beheld = CreateMobileWithStats(0x2, "Random Mobile 2");
|
||||
|
||||
var beheld = new Mobile((Serial)0x2) { Name = "Random Mobile 2" };
|
||||
beheld.DefaultMobileInit();
|
||||
beheld.Str = 50;
|
||||
beheld.Hits = 100;
|
||||
beheld.Int = 75;
|
||||
beheld.Mana = 100;
|
||||
beheld.Dex = 25;
|
||||
beheld.Stam = 100;
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = changes;
|
||||
|
||||
var expected = new MobileStatus(beholder, beheld, ns).Compile();
|
||||
ns.SendMobileStatus(beholder, beheld);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
ns => new MobileStatus(beholder, beheld, ns),
|
||||
ns => ns.SendMobileStatus(beholder, beheld),
|
||||
changes
|
||||
);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -240,33 +169,32 @@ public class MobilePacketTests
|
|||
int mobileStatusVersion
|
||||
)
|
||||
{
|
||||
var expansionInfo = ExpansionInfo.CoreExpansion;
|
||||
var oldExpansion = Core.Expansion;
|
||||
var expansionInfo = ExpansionInfo.GetInfo(expansion);
|
||||
var oldVersion = expansionInfo.MobileStatusVersion;
|
||||
Core.Expansion = expansion;
|
||||
ExpansionInfo.CoreExpansion.MobileStatusVersion = mobileStatusVersion;
|
||||
|
||||
var m = new Mobile((Serial)0x1) { Name = "Random Mobile 1" };
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 50;
|
||||
m.Hits = 100;
|
||||
m.Int = 75;
|
||||
m.Mana = 100;
|
||||
m.Dex = 25;
|
||||
m.Stam = 100;
|
||||
try
|
||||
{
|
||||
Core.Expansion = expansion;
|
||||
expansionInfo.MobileStatusVersion = mobileStatusVersion;
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = changes;
|
||||
ns.Version = new ClientVersion(version);
|
||||
ns.Flags = clientFlags;
|
||||
var m = CreateMobileWithStats(name: "Random Mobile 1");
|
||||
|
||||
var expected = new MobileStatusExtended(m, ns).Compile();
|
||||
ns.SendMobileStatus(m, m);
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = changes;
|
||||
ns.Version = new ClientVersion(version);
|
||||
ns.Flags = clientFlags;
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
Core.Expansion = oldExpansion;
|
||||
expansionInfo.MobileStatusVersion = oldVersion;
|
||||
var expected = new MobileStatusExtended(m, ns).Compile();
|
||||
ns.SendMobileStatus(m, m);
|
||||
|
||||
AssertThat.Equal(ns.SendBuffer.GetReadSpan(), expected);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Core.Expansion = oldExpansion;
|
||||
expansionInfo.MobileStatusVersion = oldVersion;
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -278,14 +206,7 @@ public class MobilePacketTests
|
|||
m.DefaultMobileInit();
|
||||
m.SolidHueOverride = solidHueOverride;
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = changes;
|
||||
|
||||
var expected = new MobileUpdate(m, ns.StygianAbyss).Compile();
|
||||
ns.SendMobileUpdate(m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(ns => new MobileUpdate(m, ns.StygianAbyss), ns => ns.SendMobileUpdate(m), changes);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -333,170 +254,82 @@ public class MobilePacketTests
|
|||
beheld.FacialHairItemID = facialHairItemId;
|
||||
beheld.FacialHairHue = facialHairHue;
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = changes;
|
||||
|
||||
var expected = new MobileIncoming(ns, beholder, beheld).Compile();
|
||||
ns.SendMobileIncoming(beholder, beheld);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
ns => new MobileIncoming(ns, beholder, beheld),
|
||||
ns => ns.SendMobileIncoming(beholder, beheld),
|
||||
changes
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMobileHits()
|
||||
{
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 100;
|
||||
m.Hits = 100;
|
||||
var m = CreateMobileWithStats();
|
||||
|
||||
var expected = new MobileHits(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileHits(m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MobileHits(m), ns => ns.SendMobileHits(m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMobileHitsN()
|
||||
{
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 100;
|
||||
m.Hits = 100;
|
||||
var m = CreateMobileWithStats();
|
||||
|
||||
var expected = new MobileHitsN(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileHits(m, true);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MobileHitsN(m), ns => ns.SendMobileHits(m, true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMobileMana()
|
||||
{
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Int = 75;
|
||||
m.Mana = 100;
|
||||
var m = CreateMobileWithStats();
|
||||
|
||||
var expected = new MobileMana(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileMana(m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MobileMana(m), ns => ns.SendMobileMana(m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMobileManaN()
|
||||
{
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Int = 75;
|
||||
m.Mana = 100;
|
||||
var m = CreateMobileWithStats();
|
||||
|
||||
var expected = new MobileManaN(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileMana(m, true);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MobileManaN(m), ns => ns.SendMobileMana(m, true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMobileStam()
|
||||
{
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Dex = 75;
|
||||
m.Stam = 100;
|
||||
var m = CreateMobileWithStats();
|
||||
|
||||
var expected = new MobileStam(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileStam(m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MobileStam(m), ns => ns.SendMobileStam(m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMobileStamN()
|
||||
{
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Dex = 75;
|
||||
m.Stam = 100;
|
||||
var m = CreateMobileWithStats();
|
||||
|
||||
var expected = new MobileStamN(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileStam(m, true);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MobileStamN(m), ns => ns.SendMobileStam(m, true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMobileAttributes()
|
||||
{
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 50;
|
||||
m.Hits = 100;
|
||||
m.Int = 75;
|
||||
m.Mana = 100;
|
||||
m.Dex = 25;
|
||||
m.Stam = 100;
|
||||
var m = CreateMobileWithStats();
|
||||
|
||||
var expected = new MobileAttributes(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileAttributes(m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MobileAttributes(m), ns => ns.SendMobileAttributes(m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMobileAttributesN()
|
||||
{
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.Str = 50;
|
||||
m.Hits = 100;
|
||||
m.Int = 75;
|
||||
m.Mana = 100;
|
||||
m.Dex = 25;
|
||||
m.Stam = 100;
|
||||
var m = CreateMobileWithStats();
|
||||
|
||||
var expected = new MobileAttributesN(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMobileAttributes(m, true);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MobileAttributesN(m), ns => ns.SendMobileAttributes(m, true));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestRemoveEntity()
|
||||
{
|
||||
var e = (Serial)0x1000;
|
||||
var expected = new RemoveEntity(e).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendRemoveEntity(e);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new RemoveEntity(e), ns => ns.SendRemoveEntity(e));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,26 +12,18 @@ public class MovementPacketTests
|
|||
[InlineData(2)]
|
||||
public void TestSpeedControl(byte speedControl)
|
||||
{
|
||||
var expected = new SpeedControl(speedControl).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendSpeedControl((SpeedControlSetting)speedControl);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new SpeedControl(speedControl),
|
||||
ns => ns.SendSpeedControl((SpeedControlSetting)speedControl)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMovePlayer()
|
||||
{
|
||||
const Direction d = Direction.Left;
|
||||
var expected = new MovePlayer(d).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMovePlayer(d);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MovePlayer(d), ns => ns.SendMovePlayer(d));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -42,13 +34,7 @@ public class MovementPacketTests
|
|||
|
||||
const byte seq = 100;
|
||||
|
||||
var expected = new MovementRej(seq, m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMovementRej(seq, m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MovementRej(seq, m), ns => ns.SendMovementRej(seq, m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -59,12 +45,6 @@ public class MovementPacketTests
|
|||
|
||||
const byte seq = 100;
|
||||
|
||||
var expected = MovementAck.Instantiate(seq, m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMovementAck(seq, m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(MovementAck.Instantiate(seq, m), ns => ns.SendMovementAck(seq, m));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,23 +8,16 @@ namespace Server.Tests.Network;
|
|||
[Collection("Sequential Server Tests")]
|
||||
public class PlayerPacketTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(StatLockType.Down, StatLockType.Up, StatLockType.Locked)]
|
||||
public void TestStatLockInfo(StatLockType str, StatLockType intel, StatLockType dex)
|
||||
[Fact]
|
||||
public void TestStatLockInfo()
|
||||
{
|
||||
var m = new Mobile((Serial)0x1);
|
||||
m.DefaultMobileInit();
|
||||
m.StrLock = str;
|
||||
m.IntLock = intel;
|
||||
m.DexLock = dex;
|
||||
m.StrLock = StatLockType.Down;
|
||||
m.IntLock = StatLockType.Up;
|
||||
m.DexLock = StatLockType.Locked;
|
||||
|
||||
var expected = new StatLockInfo(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendStatLockInfo(m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new StatLockInfo(m), ns => ns.SendStatLockInfo(m));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -33,25 +26,13 @@ public class PlayerPacketTests
|
|||
[InlineData(200)]
|
||||
public void TestChangeUpdateRange(int range)
|
||||
{
|
||||
var expected = new ChangeUpdateRange(range).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendChangeUpdateRange((byte)range);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new ChangeUpdateRange(range), ns => ns.SendChangeUpdateRange((byte)range));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDeathStatus()
|
||||
{
|
||||
var expected = new DeathStatus(false).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDeathStatus();
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new DeathStatus(false), ns => ns.SendDeathStatus());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -59,13 +40,10 @@ public class PlayerPacketTests
|
|||
[InlineData(0x1000u, null, null, null)]
|
||||
public void TestDisplayProfile(uint serial, string header, string body, string footer)
|
||||
{
|
||||
var expected = new DisplayProfile((Serial)serial, header, body, footer).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplayProfile((Serial)serial, header, body, footer);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new DisplayProfile((Serial)serial, header, body, footer),
|
||||
ns => ns.SendDisplayProfile((Serial)serial, header, body, footer)
|
||||
);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -73,55 +51,31 @@ public class PlayerPacketTests
|
|||
[InlineData(LRReason.TryToSteal)]
|
||||
public void TestLiftRej(LRReason reason)
|
||||
{
|
||||
var expected = new LiftRej(reason).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendLiftReject(reason);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new LiftRej(reason), ns => ns.SendLiftReject(reason));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestLogoutAck()
|
||||
{
|
||||
var expected = new LogoutAck().Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendLogoutAck();
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new LogoutAck(), ns => ns.SendLogoutAck());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(1, 2, 3)]
|
||||
[InlineData(4, 5, 6)]
|
||||
[InlineData(0x1234, 0x5678, 0x9ABC)]
|
||||
public void TestWeather(int type, int density, int temp)
|
||||
[InlineData(0xFF, 0x46, 0xEC)]
|
||||
public void TestWeather(byte type, byte density, byte temp)
|
||||
{
|
||||
var expected = new Weather(type, density, temp).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendWeather((byte)type, (byte)density, (byte)temp);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new Weather(type, density, temp), ns => ns.SendWeather(type, density, temp));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(100, 1000, 1, 0)]
|
||||
public void TestServerChange(int x, int y, int z, int mapID)
|
||||
[Fact]
|
||||
public void TestServerChange()
|
||||
{
|
||||
var p = new Point3D(x, y, z);
|
||||
var map = Map.Maps[mapID];
|
||||
var expected = new ServerChange(p, map).Compile();
|
||||
var p = new Point3D(100, 1000, 1);
|
||||
var map = Map.Maps[0];
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendServerChange(p, map);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new ServerChange(p, map), ns => ns.SendServerChange(p, map));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -130,13 +84,7 @@ public class PlayerPacketTests
|
|||
[InlineData(255)]
|
||||
public void TestSequence(byte num)
|
||||
{
|
||||
var expected = new Sequence(num).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendSequence(num);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new Sequence(num), ns => ns.SendSequence(num));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -146,37 +94,22 @@ public class PlayerPacketTests
|
|||
[InlineData("https://www.modernuo.com")]
|
||||
public void TestLaunchBrowser(string uri)
|
||||
{
|
||||
var expected = new LaunchBrowser(uri).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendLaunchBrowser(uri);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new LaunchBrowser(uri), ns => ns.SendLaunchBrowser(uri));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0x1000u, 1000, 100, 10, 0x2000u, 1125, 125, 5, 0x384, 1024, 25)]
|
||||
public void TestDragEffect(
|
||||
uint srcSerial, int srcX, int srcY, int srcZ,
|
||||
uint trgSerial, int trgX, int trgY, int trgZ,
|
||||
int itemId, int hue, int amount
|
||||
)
|
||||
[Fact]
|
||||
public void TestDragEffect()
|
||||
{
|
||||
var src = new Entity((Serial)srcSerial, new Point3D(srcX, srcY, srcZ), null);
|
||||
var targ = new Entity((Serial)trgSerial, new Point3D(trgX, trgY, trgZ), null);
|
||||
var src = new Entity((Serial)0x1000, new Point3D(1000, 100, 10), null);
|
||||
var targ = new Entity((Serial)0x2000, new Point3D(1125, 125, 5), null);
|
||||
const int itemId = 0x384;
|
||||
const int hue = 1024;
|
||||
const int amount = 25;
|
||||
|
||||
var expected = new DragEffect(src, targ, itemId, hue, amount).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDragEffect(
|
||||
src.Serial, src.Location,
|
||||
targ.Serial, targ.Location,
|
||||
itemId, hue, amount
|
||||
PacketAssert.Sends(
|
||||
new DragEffect(src, targ, itemId, hue, amount),
|
||||
ns => ns.SendDragEffect(src.Serial, src.Location, targ.Serial, targ.Location, itemId, hue, amount)
|
||||
);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -184,13 +117,7 @@ public class PlayerPacketTests
|
|||
[InlineData(2, true)]
|
||||
public void TestSeasonChange(int season, bool playSound)
|
||||
{
|
||||
var expected = new SeasonChange(season, playSound).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendSeasonChange((byte)season, playSound);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new SeasonChange(season, playSound), ns => ns.SendSeasonChange((byte)season, playSound));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -199,13 +126,10 @@ public class PlayerPacketTests
|
|||
[InlineData(0x1024u, "Test Title", true, false)]
|
||||
public void TestDisplayPaperdoll(uint m, string title, bool warmode, bool canLift)
|
||||
{
|
||||
var expected = new DisplayPaperdoll((Serial)m, title, warmode, canLift).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplayPaperdoll((Serial)m, title, warmode, canLift);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new DisplayPaperdoll((Serial)m, title, warmode, canLift),
|
||||
ns => ns.SendDisplayPaperdoll((Serial)m, title, warmode, canLift)
|
||||
);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -214,13 +138,7 @@ public class PlayerPacketTests
|
|||
[InlineData(MusicName.ValoriaShips)]
|
||||
public void TestPlayMusic(MusicName music)
|
||||
{
|
||||
var expected = new PlayMusic(music).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendPlayMusic(music);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new PlayMusic(music), ns => ns.SendPlayMusic(music));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -228,41 +146,23 @@ public class PlayerPacketTests
|
|||
[InlineData(100, 10, "Some more text")]
|
||||
public void TestScrollMessage(int type, int tip, string text)
|
||||
{
|
||||
var expected = new ScrollMessage(type, tip, text).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendScrollMessage(type, tip ,text);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new ScrollMessage(type, tip, text), ns => ns.SendScrollMessage(type, tip, text));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(14, 10, 05)]
|
||||
public void TestCurrentTime(int hour, int minute, int second)
|
||||
[Fact]
|
||||
public void TestCurrentTime()
|
||||
{
|
||||
var date = new DateTime(2020, 1, 1, hour, minute, second);
|
||||
var expected = new CurrentTime(date).Compile();
|
||||
var date = new DateTime(2020, 1, 1, 14, 10, 5);
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendCurrentTime(date);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new CurrentTime(date), ns => ns.SendCurrentTime(date));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(1000, 10, 1)]
|
||||
public void TestPathfindMessage(int x, int y, int z)
|
||||
[Fact]
|
||||
public void TestPathfindMessage()
|
||||
{
|
||||
var p = new Point3D(x, y, z);
|
||||
var expected = new PathfindMessage(p).Compile();
|
||||
var p = new Point3D(1000, 10, 1);
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendPathfindMessage(p);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new PathfindMessage(p), ns => ns.SendPathfindMessage(p));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -271,27 +171,17 @@ public class PlayerPacketTests
|
|||
[InlineData(100)]
|
||||
public void TestPingAck(byte ping)
|
||||
{
|
||||
var expected = new PingAck(ping).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendPingAck(ping);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new PingAck(ping), ns => ns.SendPingAck(ping));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0xFF01)]
|
||||
public void TestDisplayHuePicker(int itemID)
|
||||
[Fact]
|
||||
public void TestDisplayHuePicker()
|
||||
{
|
||||
var huePicker = new HuePicker(itemID);
|
||||
var huePicker = new HuePicker(0xFF01);
|
||||
|
||||
var expected = new DisplayHuePicker(huePicker).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplayHuePicker(huePicker.Serial, huePicker.ItemID);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new DisplayHuePicker(huePicker),
|
||||
ns => ns.SendDisplayHuePicker(huePicker.Serial, huePicker.ItemID)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,10 @@ public class SecureTradePacketTests
|
|||
var firstCont = new Container(World.NewItem);
|
||||
var secondCont = new Container(World.NewItem);
|
||||
|
||||
var expected = new DisplaySecureTrade(m, firstCont, secondCont, name).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendDisplaySecureTrade(m, firstCont, secondCont, name);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new DisplaySecureTrade(m, firstCont, secondCont, name),
|
||||
ns => ns.SendDisplaySecureTrade(m, firstCont, secondCont, name)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -32,13 +29,7 @@ public class SecureTradePacketTests
|
|||
{
|
||||
var cont = new Container(World.NewItem);
|
||||
|
||||
var expected = new CloseSecureTrade(cont).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendCloseSecureTrade(cont);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new CloseSecureTrade(cont), ns => ns.SendCloseSecureTrade(cont));
|
||||
}
|
||||
|
||||
[Theory, InlineData(true, false), InlineData(false, true)]
|
||||
|
|
@ -50,13 +41,11 @@ public class SecureTradePacketTests
|
|||
var secondCont = new Container(World.NewItem);
|
||||
|
||||
var cont = first ? firstCont : secondCont;
|
||||
var expected = new UpdateSecureTrade(cont, first, second).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendUpdateSecureTrade(cont, first, second);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new UpdateSecureTrade(cont, first, second),
|
||||
ns => ns.SendUpdateSecureTrade(cont, first, second)
|
||||
);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -65,13 +54,11 @@ public class SecureTradePacketTests
|
|||
public void TestUpdateGoldSecureTrade(int gold, int plat, TradeFlag flag)
|
||||
{
|
||||
var cont = new Container(World.NewItem);
|
||||
var expected = new UpdateSecureTrade(cont, flag, gold, plat).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendUpdateSecureTrade(cont, flag, gold, plat);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new UpdateSecureTrade(cont, flag, gold, plat),
|
||||
ns => ns.SendUpdateSecureTrade(cont, flag, gold, plat)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -83,13 +70,7 @@ public class SecureTradePacketTests
|
|||
var cont = new Container(World.NewItem);
|
||||
var itemInCont = new Item(World.NewItem) { Parent = cont };
|
||||
|
||||
var expected = new SecureTradeEquip(itemInCont, m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendSecureTradeEquip(itemInCont, m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new SecureTradeEquip(itemInCont, m), ns => ns.SendSecureTradeEquip(itemInCont, m));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -101,14 +82,10 @@ public class SecureTradePacketTests
|
|||
var cont = new Container(World.NewItem);
|
||||
var itemInCont = new Item(World.NewItem) { Parent = cont };
|
||||
|
||||
var expected = new SecureTradeEquip6017(itemInCont, m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges |= ProtocolChanges.ContainerGridLines;
|
||||
|
||||
ns.SendSecureTradeEquip(itemInCont, m);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new SecureTradeEquip6017(itemInCont, m),
|
||||
ns => ns.SendSecureTradeEquip(itemInCont, m),
|
||||
ProtocolChanges.ContainerGridLines
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,14 +38,7 @@ public class TargetPacketsTests
|
|||
var p = new Point3D(1000, 100, 10);
|
||||
MultiTarget t = new TestMultiTarget(multiID, p);
|
||||
|
||||
var expected = new MultiTargetReqHS(t).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges |= ProtocolChanges.HighSeas;
|
||||
ns.SendMultiTargetReq(t);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MultiTargetReqHS(t), ns => ns.SendMultiTargetReq(t), ProtocolChanges.HighSeas);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -55,36 +48,20 @@ public class TargetPacketsTests
|
|||
var p = new Point3D(1000, 100, 10);
|
||||
MultiTarget t = new TestMultiTarget(multiID, p);
|
||||
|
||||
var expected = new MultiTargetReq(t).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMultiTargetReq(t);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new MultiTargetReq(t), ns => ns.SendMultiTargetReq(t));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCancelTarget()
|
||||
{
|
||||
var expected = new CancelTarget().Compile();
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendCancelTarget();
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new CancelTarget(), ns => ns.SendCancelTarget());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTargetReq()
|
||||
{
|
||||
var t = new TestTarget(10, true, TargetFlags.Beneficial);
|
||||
var expected = new TargetReq(t).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendTargetReq(t);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new TargetReq(t), ns => ns.SendTargetReq(t));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,15 +22,11 @@ public class VendorBuyPacketTests
|
|||
new("Third Item", cont.Serial, World.NewItem, 30, 10, 0x0F, 0)
|
||||
};
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = protocolChanges;
|
||||
|
||||
var expected = new VendorBuyContent(buyStates, ns.ContainerGridLines).Compile();
|
||||
|
||||
ns.SendVendorBuyContent(buyStates);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
ns => new VendorBuyContent(buyStates, ns.ContainerGridLines),
|
||||
ns => ns.SendVendorBuyContent(buyStates),
|
||||
protocolChanges
|
||||
);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -41,15 +37,11 @@ public class VendorBuyPacketTests
|
|||
var vendor = new Mobile((Serial)0x1);
|
||||
vendor.DefaultMobileInit();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = protocolChanges;
|
||||
|
||||
var expected = new DisplayBuyList(vendor.Serial, ns.HighSeas).Compile();
|
||||
|
||||
ns.SendDisplayBuyList(vendor.Serial);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
ns => new DisplayBuyList(vendor.Serial, ns.HighSeas),
|
||||
ns => ns.SendDisplayBuyList(vendor.Serial),
|
||||
protocolChanges
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -67,13 +59,7 @@ public class VendorBuyPacketTests
|
|||
new("Third Item", cont.Serial, World.NewItem, 30, 10, 0x0F, 0)
|
||||
};
|
||||
|
||||
var expected = new VendorBuyList(vendor, buyStates).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendVendorBuyList(vendor, buyStates);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new VendorBuyList(vendor, buyStates), ns => ns.SendVendorBuyList(vendor, buyStates));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -82,12 +68,6 @@ public class VendorBuyPacketTests
|
|||
var vendor = new Mobile((Serial)0x1);
|
||||
vendor.DefaultMobileInit();
|
||||
|
||||
var expected = new EndVendorBuy(vendor.Serial).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendEndVendorBuy(vendor.Serial);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new EndVendorBuy(vendor.Serial), ns => ns.SendEndVendorBuy(vendor.Serial));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,13 +25,10 @@ public class VendorSellPacketTests
|
|||
new(item3, 1, "Item 3")
|
||||
};
|
||||
|
||||
var expected = new VendorSellList(vendor, sellStates.ToList()).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendVendorSellList(vendor.Serial, sellStates);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new VendorSellList(vendor, sellStates.ToList()),
|
||||
ns => ns.SendVendorSellList(vendor.Serial, sellStates)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -40,12 +37,6 @@ public class VendorSellPacketTests
|
|||
var vendor = new Mobile((Serial)0x1024u);
|
||||
vendor.DefaultMobileInit();
|
||||
|
||||
var expected = new EndVendorBuy(vendor.Serial).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendEndVendorSell(vendor.Serial);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new EndVendorSell(vendor), ns => ns.SendEndVendorSell(vendor.Serial));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,10 @@ public class VirtualHairPacketTests
|
|||
m.HairHue = 0x1000;
|
||||
m.HairItemID = 0x2000;
|
||||
|
||||
var expected = new HairEquipUpdate(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendHairEquipUpdatePacket(m, (uint)m.HairSerial, m.HairItemID, m.HairHue, Layer.Hair);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(
|
||||
new HairEquipUpdate(m),
|
||||
ns => ns.SendHairEquipUpdatePacket(m, (uint)m.HairSerial, m.HairItemID, m.HairHue, Layer.Hair)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -30,13 +27,7 @@ public class VirtualHairPacketTests
|
|||
var m = new Mobile((Serial)0x1024u);
|
||||
m.DefaultMobileInit();
|
||||
|
||||
var expected = new RemoveHair(m).Compile();
|
||||
|
||||
using var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendRemoveHairPacket((uint)m.HairSerial);
|
||||
|
||||
var result = ns.SendBuffer.GetReadSpan();
|
||||
AssertThat.Equal(result, expected);
|
||||
PacketAssert.Sends(new RemoveHair(m), ns => ns.SendRemoveHairPacket((uint)m.HairSerial));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -16,22 +16,6 @@ public sealed class HairEquipUpdate : Packet
|
|||
}
|
||||
}
|
||||
|
||||
public sealed class FacialHairEquipUpdate : Packet
|
||||
{
|
||||
public FacialHairEquipUpdate(Mobile parent)
|
||||
: base(0x2E, 15)
|
||||
{
|
||||
var hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.FacialHairHue;
|
||||
|
||||
Stream.Write(parent.FacialHairSerial);
|
||||
Stream.Write((short)parent.FacialHairItemID);
|
||||
Stream.Write((byte)0);
|
||||
Stream.Write((byte)Layer.FacialHair);
|
||||
Stream.Write(parent.Serial);
|
||||
Stream.Write((short)hue);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RemoveHair : Packet
|
||||
{
|
||||
public RemoveHair(Mobile parent)
|
||||
|
|
@ -40,12 +24,3 @@ public sealed class RemoveHair : Packet
|
|||
Stream.Write(parent.HairSerial);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RemoveFacialHair : Packet
|
||||
{
|
||||
public RemoveFacialHair(Mobile parent)
|
||||
: base(0x1D, 5)
|
||||
{
|
||||
Stream.Write(parent.FacialHairSerial);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue