fix: Fixes flaky tests, formatting, and sequential testing. (#2168)
This commit is contained in:
parent
415c7a6bfd
commit
7dbfc9d161
60 changed files with 1304 additions and 1289 deletions
|
|
@ -6,62 +6,62 @@ public sealed class MapDetails : Packet
|
|||
{
|
||||
public MapDetails(MapItem map) : base(0x90, 19)
|
||||
{
|
||||
Stream.Write(map.Serial);
|
||||
Stream.Write((short)0x139D);
|
||||
Stream.Write((short)map.Bounds.Start.X);
|
||||
Stream.Write((short)map.Bounds.Start.Y);
|
||||
Stream.Write((short)map.Bounds.End.X);
|
||||
Stream.Write((short)map.Bounds.End.Y);
|
||||
Stream.Write((short)map.Width);
|
||||
Stream.Write((short)map.Height);
|
||||
}
|
||||
Stream.Write(map.Serial);
|
||||
Stream.Write((short)0x139D);
|
||||
Stream.Write((short)map.Bounds.Start.X);
|
||||
Stream.Write((short)map.Bounds.Start.Y);
|
||||
Stream.Write((short)map.Bounds.End.X);
|
||||
Stream.Write((short)map.Bounds.End.Y);
|
||||
Stream.Write((short)map.Width);
|
||||
Stream.Write((short)map.Height);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MapDetailsNew : Packet
|
||||
{
|
||||
public MapDetailsNew(MapItem map) : base(0xF5, 21)
|
||||
{
|
||||
Stream.Write(map.Serial);
|
||||
Stream.Write((short)0x139D);
|
||||
Stream.Write((short)map.Bounds.Start.X);
|
||||
Stream.Write((short)map.Bounds.Start.Y);
|
||||
Stream.Write((short)map.Bounds.End.X);
|
||||
Stream.Write((short)map.Bounds.End.Y);
|
||||
Stream.Write((short)map.Width);
|
||||
Stream.Write((short)map.Height);
|
||||
Stream.Write((short)(map.Facet?.MapID ?? 0));
|
||||
}
|
||||
Stream.Write(map.Serial);
|
||||
Stream.Write((short)0x139D);
|
||||
Stream.Write((short)map.Bounds.Start.X);
|
||||
Stream.Write((short)map.Bounds.Start.Y);
|
||||
Stream.Write((short)map.Bounds.End.X);
|
||||
Stream.Write((short)map.Bounds.End.Y);
|
||||
Stream.Write((short)map.Width);
|
||||
Stream.Write((short)map.Height);
|
||||
Stream.Write((short)(map.Facet?.MapID ?? 0));
|
||||
}
|
||||
}
|
||||
|
||||
public class MapCommand : Packet
|
||||
{
|
||||
public MapCommand(MapItem map, int command, int number, int x, int y) : base(0x56, 11)
|
||||
{
|
||||
Stream.Write(map.Serial);
|
||||
Stream.Write((byte)command);
|
||||
Stream.Write((byte)number);
|
||||
Stream.Write((short)x);
|
||||
Stream.Write((short)y);
|
||||
}
|
||||
Stream.Write(map.Serial);
|
||||
Stream.Write((byte)command);
|
||||
Stream.Write((byte)number);
|
||||
Stream.Write((short)x);
|
||||
Stream.Write((short)y);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MapDisplay : MapCommand
|
||||
{
|
||||
public MapDisplay(MapItem map) : base(map, 5, 0, 0, 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MapAddPin : MapCommand
|
||||
{
|
||||
public MapAddPin(MapItem map, Point2D point) : base(map, 1, 0, point.X, point.Y)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MapSetEditable : MapCommand
|
||||
{
|
||||
public MapSetEditable(MapItem map, bool editable) : base(map, 7, editable ? 1 : 0, 0, 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,26 +7,26 @@ using Xunit;
|
|||
|
||||
namespace UOContent.Tests;
|
||||
|
||||
[Collection("Sequential Tests")]
|
||||
public class TestMapItemPackets : IClassFixture<ServerFixture>
|
||||
[Collection("Sequential UOContent Tests")]
|
||||
public class TestMapItemPackets
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(ProtocolChanges.NewCharacterList)]
|
||||
[InlineData(ProtocolChanges.None)]
|
||||
public void TestSendMapDetails(ProtocolChanges changes)
|
||||
{
|
||||
var mapItem = new MapItem(Map.Trammel);
|
||||
var mapItem = new MapItem(Map.Trammel);
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = changes;
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.ProtocolChanges = changes;
|
||||
|
||||
var expected = (ns.NewCharacterList ?
|
||||
(Packet)new MapDetailsNew(mapItem) : new MapDetails(mapItem)).Compile();
|
||||
ns.SendMapDetails(mapItem);
|
||||
var expected = (ns.NewCharacterList ?
|
||||
(Packet)new MapDetailsNew(mapItem) : new MapDetails(mapItem)).Compile();
|
||||
ns.SendMapDetails(mapItem);
|
||||
|
||||
var result = ns.SendPipe.Reader.AvailableToRead();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(5, 0, 0, 0)]
|
||||
|
|
@ -35,14 +35,14 @@ public class TestMapItemPackets : IClassFixture<ServerFixture>
|
|||
[InlineData(7, 0, 0, 0)]
|
||||
public void TestSendMapCommand(int command, int number, int x, int y)
|
||||
{
|
||||
var mapItem = new MapItem(Map.Trammel);
|
||||
var mapItem = new MapItem(Map.Trammel);
|
||||
|
||||
var expected = new MapCommand(mapItem, command, number, x, y).Compile();
|
||||
var expected = new MapCommand(mapItem, command, number, x, y).Compile();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMapCommand(mapItem, command, x, y, number > 0);
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
ns.SendMapCommand(mapItem, command, x, y, number > 0);
|
||||
|
||||
var result = ns.SendPipe.Reader.AvailableToRead();
|
||||
AssertThat.Equal(result, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue