Add a few simple tests
Ensure the struct sizes are correct
This commit is contained in:
parent
734db17bb9
commit
c42241d834
|
@ -304,7 +304,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||
_udpEndpoint = new IPEndPoint(response.BoundAddress, response.BoundPort);
|
||||
_udpSocket = new Socket(AddressFamily, SocketType, ProtocolType)
|
||||
{
|
||||
Blocking = Socket.Blocking
|
||||
Blocking = Socket.Blocking,
|
||||
};
|
||||
_udpSocket.Bind(endpoint);
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
using NUnit.Framework;
|
||||
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy.Auth;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Tests.HLE.HOS.Services.Sockets.Bsd.Proxy.Auth
|
||||
{
|
||||
public class AuthMethodTests
|
||||
{
|
||||
[Test]
|
||||
public void GetAuth_ReturnValue([Values] AuthMethod authMethod)
|
||||
{
|
||||
// TODO: Remove this as soon as we have an implementation for these
|
||||
if (authMethod is AuthMethod.UsernameAndPassword or AuthMethod.GSSAPI)
|
||||
{
|
||||
Assert.Throws<NotImplementedException>(() => authMethod.GetAuth());
|
||||
return;
|
||||
}
|
||||
|
||||
if (authMethod is AuthMethod.NoAcceptableMethods)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => authMethod.GetAuth());
|
||||
return;
|
||||
}
|
||||
|
||||
Assert.IsInstanceOf<IProxyAuth>(authMethod.GetAuth());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
using NUnit.Framework;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy;
|
||||
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy.Auth;
|
||||
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy.Packets;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Tests.HLE.HOS.Services.Sockets.Bsd.Proxy.Packets
|
||||
{
|
||||
public class MethodSelectionTests
|
||||
{
|
||||
[Test]
|
||||
public void MethodSelectionRequest1_Size()
|
||||
{
|
||||
// Version: 1 byte
|
||||
// Number of methods: 1 byte
|
||||
// Methods: 1 - 255 bytes (in this case: 1)
|
||||
// Total: 3 bytes
|
||||
|
||||
var request = new MethodSelectionRequest1
|
||||
{
|
||||
Version = ProxyConsts.Version,
|
||||
NumOfMethods = 1,
|
||||
Methods = new Array1<AuthMethod> { [0] = AuthMethod.NoAuthenticationRequired },
|
||||
};
|
||||
|
||||
Assert.AreEqual(3, Marshal.SizeOf(request));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MethodSelectionResponse_Size()
|
||||
{
|
||||
// Version: 1 byte
|
||||
// Method: 1 byte
|
||||
// Total: 2 bytes
|
||||
|
||||
var response = new MethodSelectionResponse()
|
||||
{
|
||||
Version = ProxyConsts.Version,
|
||||
Method = AuthMethod.NoAuthenticationRequired,
|
||||
};
|
||||
|
||||
Assert.AreEqual(2, Marshal.SizeOf(response));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue