Files
RobustToolbox/Robust.Shared.IntegrationTests/TestRobustSerializerHash.cs
PJB3005 788e9386fd Split up test project
Robust.UnitTesting was both ALL tests for RT, and also API surface for content tests.

Tests are now split into separate projects as appropriate, and the API side has also been split off.
2025-12-16 01:36:53 +01:00

44 lines
1.4 KiB
C#

using System.IO;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Robust.UnitTesting.Shared;
[Parallelizable(ParallelScope.All)]
internal sealed class TestRobustSerializerHash : RobustIntegrationTest
{
/// <summary>
/// Test that the serializer hash on client and server matches.
/// </summary>
[Test]
public async Task Test()
{
var server = StartServer();
var client = StartClient();
var manifestServerStream = new MemoryStream();
var manifestClientStream = new MemoryStream();
await server.WaitPost(() =>
{
var serializer = (RobustSerializer) IoCManager.Resolve<IRobustSerializer>();
serializer.GetHashManifest(manifestServerStream, writeNewline: true);
});
await client.WaitPost(() =>
{
var serializer = (RobustSerializer) IoCManager.Resolve<IRobustSerializer>();
serializer.GetHashManifest(manifestClientStream, writeNewline: true);
});
var manifestServer = Encoding.UTF8.GetString(manifestServerStream.AsSpan());
var manifestClient = Encoding.UTF8.GetString(manifestClientStream.AsSpan());
Assert.That(manifestServer, NUnit.Framework.Is.EqualTo(manifestClient));
}
}