From bbdb561de84f52268d8566ba77c964bea8011f37 Mon Sep 17 00:00:00 2001
From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com>
Date: Sun, 6 Sep 2020 14:16:57 -0700
Subject: [PATCH] Fixes leaking tests (#231)
---
Directory.Build.props | 6 +-
.../Old/Outgoing/AttributeNormalizerTests.cs | 1 +
.../Packets/Old/Outgoing/MobilePacketTests.cs | 300 +++++++++---------
.../SequentialTestCollectionDefinition.cs | 9 +
4 files changed, 166 insertions(+), 150 deletions(-)
create mode 100644 Projects/Server.Tests/SequentialTestCollectionDefinition.cs
diff --git a/Directory.Build.props b/Directory.Build.props
index fa59f0e06..63990ace3 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -9,8 +9,6 @@
x64
8.0
true
- WINDOWS
- UNIX
true
NU1603
win-x64;debian.10-x64;debian.9-x64;ubuntu.16.04-x64;ubuntu.18.04-x64;ubuntu.20.04-x64;centos.7-x64;centos.8-x64;osx-x64
@@ -23,6 +21,10 @@
true
true
true
+ WINDOWS
+ OSX
+ LINUX
+ UNIX
true
diff --git a/Projects/Server.Tests/Network/Packets/Old/Outgoing/AttributeNormalizerTests.cs b/Projects/Server.Tests/Network/Packets/Old/Outgoing/AttributeNormalizerTests.cs
index c349bbe65..2b8b8cd1a 100644
--- a/Projects/Server.Tests/Network/Packets/Old/Outgoing/AttributeNormalizerTests.cs
+++ b/Projects/Server.Tests/Network/Packets/Old/Outgoing/AttributeNormalizerTests.cs
@@ -5,6 +5,7 @@ using Xunit;
namespace Server.Tests.Network.Packets
{
+ [Collection("Sequential Tests")]
public class AttributeNormalizerTests
{
[Fact]
diff --git a/Projects/Server.Tests/Network/Packets/Old/Outgoing/MobilePacketTests.cs b/Projects/Server.Tests/Network/Packets/Old/Outgoing/MobilePacketTests.cs
index d649f791f..813696c28 100644
--- a/Projects/Server.Tests/Network/Packets/Old/Outgoing/MobilePacketTests.cs
+++ b/Projects/Server.Tests/Network/Packets/Old/Outgoing/MobilePacketTests.cs
@@ -106,154 +106,6 @@ namespace Server.Tests.Network.Packets
AssertThat.Equal(data, expectedData);
}
- [Fact]
- public void TestMobileHits()
- {
- var m = new Mobile(0x1);
- m.DefaultMobileInit();
-
- var data = new MobileHits(m).Compile();
-
- Span expectedData = stackalloc byte[9];
- var pos = 0;
-
- expectedData.Write(ref pos, (byte)0xA1); // Packet ID
- expectedData.Write(ref pos, m.Serial);
- expectedData.WriteAttribute(ref pos, m.Hits, m.HitsMax, false);
-
- AssertThat.Equal(data, expectedData);
- }
-
- [Fact]
- public void TestMobileHitsN()
- {
- var m = new Mobile(0x1);
- m.DefaultMobileInit();
-
- var data = new MobileHitsN(m).Compile();
-
- Span expectedData = stackalloc byte[9];
- var pos = 0;
-
- expectedData.Write(ref pos, (byte)0xA1); // Packet ID
- expectedData.Write(ref pos, m.Serial);
- expectedData.WriteAttribute(ref pos, m.Hits, m.HitsMax, true);
-
- AssertThat.Equal(data, expectedData);
- }
-
- [Fact]
- public void TestMobileMana()
- {
- var m = new Mobile(0x1);
- m.DefaultMobileInit();
-
- var data = new MobileMana(m).Compile();
-
- Span expectedData = stackalloc byte[9];
- var pos = 0;
-
- expectedData.Write(ref pos, (byte)0xA2); // Packet ID
- expectedData.Write(ref pos, m.Serial);
- expectedData.WriteAttribute(ref pos, m.Mana, m.ManaMax, false);
-
- AssertThat.Equal(data, expectedData);
- }
-
- [Fact]
- public void TestMobileManaN()
- {
- var m = new Mobile(0x1);
- m.DefaultMobileInit();
-
- var data = new MobileManaN(m).Compile();
-
- Span expectedData = stackalloc byte[9];
- var pos = 0;
-
- expectedData.Write(ref pos, (byte)0xA2); // Packet ID
- expectedData.Write(ref pos, m.Serial);
- expectedData.WriteAttribute(ref pos, m.Mana, m.ManaMax, true);
-
- AssertThat.Equal(data, expectedData);
- }
-
- [Fact]
- public void TestMobileStam()
- {
- var m = new Mobile(0x1);
- m.DefaultMobileInit();
-
- var data = new MobileStam(m).Compile();
-
- Span expectedData = stackalloc byte[9];
- var pos = 0;
-
- expectedData.Write(ref pos, (byte)0xA3); // Packet ID
- expectedData.Write(ref pos, m.Serial);
- expectedData.WriteAttribute(ref pos, m.Stam, m.StamMax, false);
-
- AssertThat.Equal(data, expectedData);
- }
-
- [Fact]
- public void TestMobileStamN()
- {
- var m = new Mobile(0x1);
- m.DefaultMobileInit();
-
- var data = new MobileStamN(m).Compile();
-
- Span expectedData = stackalloc byte[9];
- var pos = 0;
-
- expectedData.Write(ref pos, (byte)0xA3); // Packet ID
- expectedData.Write(ref pos, m.Serial);
- expectedData.WriteAttribute(ref pos, m.Stam, m.StamMax, true);
-
- AssertThat.Equal(data, expectedData);
- }
-
- [Fact]
- public void TestMobileAttributes()
- {
- var m = new Mobile(0x1);
- m.DefaultMobileInit();
-
- var data = new MobileAttributes(m).Compile();
-
- Span expectedData = stackalloc byte[17];
- var pos = 0;
-
- expectedData.Write(ref pos, (byte)0x2D); // Packet ID
- expectedData.Write(ref pos, m.Serial);
- expectedData.WriteAttribute(ref pos, m.Hits, m.HitsMax, false);
- expectedData.WriteAttribute(ref pos, m.Mana, m.ManaMax, false);
- expectedData.WriteAttribute(ref pos, m.Stam, m.StamMax, false);
-
- AssertThat.Equal(data, expectedData);
- }
-
- [Fact]
- public void TestMobileAttributesN()
- {
- var m = new Mobile(0x1);
- m.DefaultMobileInit();
-
- var data = new MobileAttributesN(m).Compile();
-
- Span expectedData = stackalloc byte[17];
- var pos = 0;
-
- expectedData.Write(ref pos, (byte)0x2D); // Packet ID
- expectedData.Write(ref pos, m.Serial);
- expectedData.WriteAttribute(ref pos, m.Hits, m.HitsMax, true);
- expectedData.WriteAttribute(ref pos, m.Mana, m.ManaMax, true);
- expectedData.WriteAttribute(ref pos, m.Stam, m.StamMax, true);
-
- AssertThat.Equal(data, expectedData);
- }
-
[Fact]
public void TestMobileName()
{
@@ -887,4 +739,156 @@ namespace Server.Tests.Network.Packets
AssertThat.Equal(data, expectedData);
}
}
+
+ [Collection("Sequential Tests")]
+ public class SequentialMobilePacketTests : IClassFixture
+ {
+ [Fact]
+ public void TestMobileHits()
+ {
+ var m = new Mobile(0x1);
+ m.DefaultMobileInit();
+
+ var data = new MobileHits(m).Compile();
+
+ Span expectedData = stackalloc byte[9];
+ var pos = 0;
+
+ expectedData.Write(ref pos, (byte)0xA1); // Packet ID
+ expectedData.Write(ref pos, m.Serial);
+ expectedData.WriteAttribute(ref pos, m.Hits, m.HitsMax, false);
+
+ AssertThat.Equal(data, expectedData);
+ }
+
+ [Fact]
+ public void TestMobileHitsN()
+ {
+ var m = new Mobile(0x1);
+ m.DefaultMobileInit();
+
+ var data = new MobileHitsN(m).Compile();
+
+ Span expectedData = stackalloc byte[9];
+ var pos = 0;
+
+ expectedData.Write(ref pos, (byte)0xA1); // Packet ID
+ expectedData.Write(ref pos, m.Serial);
+ expectedData.WriteAttribute(ref pos, m.Hits, m.HitsMax, true);
+
+ AssertThat.Equal(data, expectedData);
+ }
+
+ [Fact]
+ public void TestMobileMana()
+ {
+ var m = new Mobile(0x1);
+ m.DefaultMobileInit();
+
+ var data = new MobileMana(m).Compile();
+
+ Span expectedData = stackalloc byte[9];
+ var pos = 0;
+
+ expectedData.Write(ref pos, (byte)0xA2); // Packet ID
+ expectedData.Write(ref pos, m.Serial);
+ expectedData.WriteAttribute(ref pos, m.Mana, m.ManaMax, false);
+
+ AssertThat.Equal(data, expectedData);
+ }
+
+ [Fact]
+ public void TestMobileManaN()
+ {
+ var m = new Mobile(0x1);
+ m.DefaultMobileInit();
+
+ var data = new MobileManaN(m).Compile();
+
+ Span expectedData = stackalloc byte[9];
+ var pos = 0;
+
+ expectedData.Write(ref pos, (byte)0xA2); // Packet ID
+ expectedData.Write(ref pos, m.Serial);
+ expectedData.WriteAttribute(ref pos, m.Mana, m.ManaMax, true);
+
+ AssertThat.Equal(data, expectedData);
+ }
+
+ [Fact]
+ public void TestMobileStam()
+ {
+ var m = new Mobile(0x1);
+ m.DefaultMobileInit();
+
+ var data = new MobileStam(m).Compile();
+
+ Span expectedData = stackalloc byte[9];
+ var pos = 0;
+
+ expectedData.Write(ref pos, (byte)0xA3); // Packet ID
+ expectedData.Write(ref pos, m.Serial);
+ expectedData.WriteAttribute(ref pos, m.Stam, m.StamMax, false);
+
+ AssertThat.Equal(data, expectedData);
+ }
+
+ [Fact]
+ public void TestMobileStamN()
+ {
+ var m = new Mobile(0x1);
+ m.DefaultMobileInit();
+
+ var data = new MobileStamN(m).Compile();
+
+ Span expectedData = stackalloc byte[9];
+ var pos = 0;
+
+ expectedData.Write(ref pos, (byte)0xA3); // Packet ID
+ expectedData.Write(ref pos, m.Serial);
+ expectedData.WriteAttribute(ref pos, m.Stam, m.StamMax, true);
+
+ AssertThat.Equal(data, expectedData);
+ }
+
+ [Fact]
+ public void TestMobileAttributes()
+ {
+ var m = new Mobile(0x1);
+ m.DefaultMobileInit();
+
+ var data = new MobileAttributes(m).Compile();
+
+ Span expectedData = stackalloc byte[17];
+ var pos = 0;
+
+ expectedData.Write(ref pos, (byte)0x2D); // Packet ID
+ expectedData.Write(ref pos, m.Serial);
+ expectedData.WriteAttribute(ref pos, m.Hits, m.HitsMax, false);
+ expectedData.WriteAttribute(ref pos, m.Mana, m.ManaMax, false);
+ expectedData.WriteAttribute(ref pos, m.Stam, m.StamMax, false);
+
+ AssertThat.Equal(data, expectedData);
+ }
+
+ [Fact]
+ public void TestMobileAttributesN()
+ {
+ var m = new Mobile(0x1);
+ m.DefaultMobileInit();
+
+ var data = new MobileAttributesN(m).Compile();
+
+ Span expectedData = stackalloc byte[17];
+ var pos = 0;
+
+ expectedData.Write(ref pos, (byte)0x2D); // Packet ID
+ expectedData.Write(ref pos, m.Serial);
+ expectedData.WriteAttribute(ref pos, m.Hits, m.HitsMax, true);
+ expectedData.WriteAttribute(ref pos, m.Mana, m.ManaMax, true);
+ expectedData.WriteAttribute(ref pos, m.Stam, m.StamMax, true);
+
+ AssertThat.Equal(data, expectedData);
+ }
+ }
}
diff --git a/Projects/Server.Tests/SequentialTestCollectionDefinition.cs b/Projects/Server.Tests/SequentialTestCollectionDefinition.cs
new file mode 100644
index 000000000..2db7f513c
--- /dev/null
+++ b/Projects/Server.Tests/SequentialTestCollectionDefinition.cs
@@ -0,0 +1,9 @@
+using Xunit;
+
+namespace Server.Tests
+{
+ [CollectionDefinition("Sequential Tests", DisableParallelization = true)]
+ public class SequentialTestCollectionDefinition
+ {
+ }
+}