diff --git a/Content.IntegrationTests/Content.IntegrationTests.csproj b/Content.IntegrationTests/Content.IntegrationTests.csproj index facf846aee..c117660cee 100644 --- a/Content.IntegrationTests/Content.IntegrationTests.csproj +++ b/Content.IntegrationTests/Content.IntegrationTests.csproj @@ -12,6 +12,7 @@ + diff --git a/Content.IntegrationTests/Tests/SerializerTest.cs b/Content.IntegrationTests/Tests/SerializerTest.cs new file mode 100644 index 0000000000..108bcc92e9 --- /dev/null +++ b/Content.IntegrationTests/Tests/SerializerTest.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Moq; +using NUnit.Framework; +using Robust.Server.Interfaces.GameObjects; +using Robust.Server.Interfaces.Player; +using Robust.Shared.Enums; +using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Interfaces.Network; +using Robust.Shared.Interfaces.Serialization; +using Robust.Shared.IoC; +using Robust.Shared.Serialization; +using Robust.Shared.Timing; +using Is = NUnit.DeepObjectCompare.Is; + +namespace Content.IntegrationTests.Tests +{ + + public class SerializerTest : ContentIntegrationTest + { + + [Test] + public async Task EntityStatesTest() + { + RobustSerializer._traceWriter = Console.Out; + var client = StartClient(); + var server = StartServer(); + + await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync()); + + // Connect. + + client.SetConnectTarget(server); + + client.Post(() => IoCManager.Resolve().ClientConnect(null, 0, null)); + + // Run some ticks for the handshake to complete and such. + + server.RunTicks(1); + await server.WaitIdleAsync(); + client.RunTicks(1); + await client.WaitIdleAsync(); + + await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync()); + + // Basic checks to ensure that they're connected and data got replicated. + + var mtx = new ManualResetEventSlim(); + List es = null; + + server.Post(() => + { + var sem = IoCManager.Resolve(); + es = sem.GetEntityStates(GameTick.Zero); + mtx.Set(); + }); + mtx.Wait(); + + Assert.NotNull(es); + + var serializer = new RobustSerializer(); + + List roundTrip; + + using (var ms = new MemoryStream()) + { + serializer.Serialize(ms, es); + ms.Position = 0; + roundTrip = (List)serializer.Deserialize(ms); + } + + Assert.That(roundTrip, Is.DeepEqualTo(es)); + + } + + } + +} diff --git a/SpaceStation14.sln b/SpaceStation14.sln index 5f39c0fd76..7bde6a2e58 100644 --- a/SpaceStation14.sln +++ b/SpaceStation14.sln @@ -115,10 +115,10 @@ Global {4809F412-3132-419E-BF9D-CCF7593C3533}.Debug|x64.Build.0 = Debug|x64 {4809F412-3132-419E-BF9D-CCF7593C3533}.Release|x64.ActiveCfg = Release|x64 {4809F412-3132-419E-BF9D-CCF7593C3533}.Release|x64.Build.0 = Release|x64 - {45C9B43F-305D-4651-9863-F6384CBC847F}.Debug|x64.ActiveCfg = Debug|Any CPU - {45C9B43F-305D-4651-9863-F6384CBC847F}.Debug|x64.Build.0 = Debug|Any CPU - {45C9B43F-305D-4651-9863-F6384CBC847F}.Release|x64.ActiveCfg = Release|Any CPU - {45C9B43F-305D-4651-9863-F6384CBC847F}.Release|x64.Build.0 = Release|Any CPU + {45C9B43F-305D-4651-9863-F6384CBC847F}.Debug|x64.ActiveCfg = Debug|x64 + {45C9B43F-305D-4651-9863-F6384CBC847F}.Debug|x64.Build.0 = Debug|x64 + {45C9B43F-305D-4651-9863-F6384CBC847F}.Release|x64.ActiveCfg = Release|x64 + {45C9B43F-305D-4651-9863-F6384CBC847F}.Release|x64.Build.0 = Release|x64 {A3A97D48-6128-4330-B962-B4A96F018CE8}.Debug|x64.ActiveCfg = Debug|Any CPU {A3A97D48-6128-4330-B962-B4A96F018CE8}.Debug|x64.Build.0 = Debug|Any CPU {A3A97D48-6128-4330-B962-B4A96F018CE8}.Release|x64.ActiveCfg = Release|Any CPU