fix(core): Converts more packets and switches to Moq (#415)

- [X] Switches testing to moq for mocking
- [X] Converts race changer packets
- [X] Renames some more folders and misc cleanup
This commit is contained in:
Kamron Batman 2021-01-16 22:09:05 -08:00 • committed by GitHub
parent fbafd7210d
commit b4b1b0b122
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
144 changed files with 197 additions and 181 deletions

View file

@ -1,4 +1,7 @@
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using Moq;
using Server.Network;
namespace Server.Tests.Network
@ -8,7 +11,18 @@ namespace Server.Tests.Network
public static Span<byte> Compile(this Packet p) =>
p.Compile(false, out var length).AsSpan(0, length);
public static NetState CreateTestNetState() =>
new(new MockSocket());
public static NetState CreateTestNetState()
{
var socket = new Mock<ISocket>();
socket
.Setup(s => s.SendAsync(It.IsAny<IList<ArraySegment<byte>>>(), SocketFlags.None))
.ReturnsAsync(() => 0);
socket
.Setup(s => s.ReceiveAsync(It.IsAny<IList<ArraySegment<byte>>>(), SocketFlags.None))
.ReturnsAsync(() => 0);
return new NetState(socket.Object);
}
}
}