Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions ClassicAssist.Tests/EngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public unsafe void WillSendPacket()
{
fixed ( void* func = &_pluginHeader )
{
Engine.Install( (PluginHeader*) func );
Engine.Initialize();
Engine.InitializePlugin( (PluginHeader*) func );
}

using ( AutoResetEvent are = new AutoResetEvent( false ) )
Expand Down Expand Up @@ -149,7 +150,8 @@ public unsafe void WillFilterSendPacket()
{
fixed ( void* func = &_pluginHeader )
{
Engine.Install( (PluginHeader*) func );
Engine.Initialize();
Engine.InitializePlugin( (PluginHeader*) func );
}

byte[] packet = { 0x06, 0xAA, 0xBB, 0xCC, 0xDD };
Expand Down Expand Up @@ -197,7 +199,8 @@ public unsafe void WillFilterReceivedPacket()
{
fixed ( void* func = &_pluginHeader )
{
Engine.Install( (PluginHeader*) func );
Engine.Initialize();
Engine.InitializePlugin( (PluginHeader*) func );
}

byte[] packet = { 0x2F, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 };
Expand Down Expand Up @@ -246,7 +249,8 @@ public unsafe void WillReceivePacket()
{
fixed ( void* func = &_pluginHeader )
{
Engine.Install( (PluginHeader*) func );
Engine.Initialize();
Engine.InitializePlugin( (PluginHeader*) func );
}

byte[] packet = { 0x2F, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 };
Expand Down
8 changes: 8 additions & 0 deletions ClassicAssist.Tests/IncomingPacketHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ public void Initialize()
IncomingPacketHandlers.Initialize();
}

[TestCleanup]
public void Cleanup()
{
Engine.Player = null;
Engine.Items = new ItemCollection( 0 );
Engine.Mobiles = new MobileCollection( Engine.Items );
}

[TestMethod]
public void ContainerContentsWillAddToPlayerBackpack()
{
Expand Down
4 changes: 4 additions & 0 deletions ClassicAssist.Tests/MacroCommands/ActionCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@ public void WillFindLayer()
public void Cleanup()
{
ActionPacketQueue.Clear();
Engine.Player = null;
Engine.Items.Clear();
Engine.Mobiles.Clear();
AliasCommands._aliases.Clear();
}
}
}
7 changes: 7 additions & 0 deletions ClassicAssist.Tests/MacroCommands/AliasCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ public void Initialize()
Engine.Player = _player;
}

[TestCleanup]
public void Cleanup()
{
Engine.Player = null;
AliasCommands._aliases.Clear();
}

[TestMethod]
public void WillSetDefaultAliases()
{
Expand Down
6 changes: 6 additions & 0 deletions ClassicAssist.Tests/MacroCommands/JournalCommandsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,11 @@ public void BufferWrapsAround()

// Engine.Journal.Clear();
//}

[TestCleanup]
public void Cleanup()
{
Engine.Journal = new CircularBuffer<JournalEntry>( 1024 );
}
}
}
5 changes: 5 additions & 0 deletions ClassicAssist.Tests/MacroCommands/ObjectCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ public void WillFindTypeStackAmountIgnoreIfMobile()
public void Cleanup()
{
ActionPacketQueue.Clear();
Engine.Player = null;
Engine.Items.Clear();
Engine.Mobiles.Clear();
ObjectCommands.ClearIgnoreList();
AliasCommands._aliases.Clear();
}
}
}
25 changes: 19 additions & 6 deletions ClassicAssist.Tests/MacroCommands/PropertiesCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ namespace ClassicAssist.Tests.MacroCommands
[TestClass]
public class PropertiesCommandTests
{
private Engine.dSendRecvPacket _internalPacketSentHandler;

[TestMethod]
public void WillWaitForProperties()
{
Engine.PacketWaitEntries = new PacketWaitEntries();

void OnInternalPacketSentEvent( byte[] data, int length )
_internalPacketSentHandler = ( byte[] data, int length ) =>
{
if ( data[0] != 0xD6 )
{
Expand All @@ -31,16 +33,13 @@ void OnInternalPacketSentEvent( byte[] data, int length )
byte[] packet = { 0xD6, 0x00, 0x09, 0x00, 0x01, data[3], data[4], data[5], data[6] };

Engine.PacketWaitEntries.CheckWait( packet, PacketDirection.Incoming );
}
};

Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;
Engine.InternalPacketSentEvent += _internalPacketSentHandler;

bool result = PropertiesCommands.WaitForProperties( 0x00aabbcc, 5000 );

Assert.IsTrue( result );

Engine.PacketWaitEntries = null;
Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
}

[TestMethod]
Expand Down Expand Up @@ -117,5 +116,19 @@ public void WillGetPropertyValue()

Engine.Items.Clear();
}

[TestCleanup]
public void Cleanup()
{
if ( _internalPacketSentHandler != null )
{
Engine.InternalPacketSentEvent -= _internalPacketSentHandler;
_internalPacketSentHandler = null;
}

Engine.Player = null;
Engine.Items.Clear();
Engine.PacketWaitEntries = null;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
}
13 changes: 13 additions & 0 deletions ClassicAssist.Tests/MacroCommands/TargetCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,5 +1192,18 @@ public void WillWaitForTargetMultiTarget()
Engine.PacketWaitEntries = null;
}
}

[TestCleanup]
public void Cleanup()
{
Engine.Player = null;
Engine.Mobiles.Clear();
Engine.Items.Clear();
Engine.PacketWaitEntries = null;
Options.CurrentOptions.GetFriendEnemyUsesIgnoreList = false;
Options.CurrentOptions.Friends.Clear();
ObjectCommands.ClearIgnoreList();
AliasCommands._aliases.Clear();
}
}
}
3 changes: 3 additions & 0 deletions ClassicAssist.Tests/OutgoingPacketHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public void WontThrowExceptionDuplicateKey()
[TestCleanup]
public void Cleanup()
{
Engine.Player = null;
Engine.Items = new ItemCollection( 0 );
Engine.Mobiles = new MobileCollection( Engine.Items );
}
}
}
8 changes: 8 additions & 0 deletions ClassicAssist.Tests/SpellCommandsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,13 @@ public void CastWillSetWaitingFalseFizzleDetection()
Engine.Player = null;
Engine.PacketWaitEntries = null;
}

[TestCleanup]
public void Cleanup()
{
Engine.Player = null;
Engine.PacketWaitEntries = null;
Options.CurrentOptions.UseExperimentalFizzleDetection = false;
}
}
}
Loading