static void TestParseStateSync(ITestPlatformSupport platform, String fileName) { mtest.publishable_seven_subscriber subs = new mtest.publishable_seven_subscriber(); SimpleBuffer buffer = SimpleBuffer.readFromFile(fileName); IPublishableParser parser = platform.makePublishableParser(buffer.getReadIterator()); subs.applyStateSyncMessage(parser); //mtest.publishable_seven actual = (mtest.publishable_seven)subs.debugOnlyGetData(); mtest.publishable_seven expected = GetPublishableSeven(); Assert.True(expected.isEquivalent(subs)); }
static void TestComposeStateSync(ITestPlatformSupport platform, String fileName) { mtest.publishable_seven_publisher publ = new mtest.publishable_seven_publisher(); mtest.publishable_seven data = GetPublishableSeven(); publ.debugOnlySetData(data); SimpleBuffer buffer = new SimpleBuffer(); IPublishableComposer composer = platform.makePublishableComposer(buffer); publ.generateStateSyncMessage(composer); if (WriteFiles) { buffer.writeToFile(fileName); } SimpleBuffer expected = SimpleBuffer.readFromFile(fileName); Assert.True(platform.AreEqual(expected, buffer)); }
public static mtest.publishable_seven GetPublishableSeven() { mtest.publishable_seven data = new mtest.publishable_seven(); data.intVec = new List <Int64>(); data.intVec.Add(1); data.intVec.Add(2); data.intVec.Add(3); data.uintVec = new List <UInt64>(); data.uintVec.Add(4); data.uintVec.Add(5); data.uintVec.Add(6); data.realVec = new List <Double>(); data.realVec.Add(7); data.realVec.Add(8); data.realVec.Add(9); data.strVec = new List <String>(); data.strVec.Add("one"); data.strVec.Add("two"); data.strVec.Add("three"); data.structVec = new List <mtest.Ipoint3D>(); mtest.Ipoint3D e1 = new mtest.point3D(); e1.x = 101; e1.y = 102; e1.z = 103; data.structVec.Add(e1); mtest.Ipoint3D e2 = new mtest.point3D(); e2.x = 201; e2.y = 202; e2.z = 203; data.structVec.Add(e2); return(data); }
static void TestParseUpdate(ITestPlatformSupport platform, String fileNameInit, String fileName, Action <mtest.Ipublishable_seven> updateDelegate) { mtest.publishable_seven_subscriber subs = new mtest.publishable_seven_subscriber(); //subs.debugOnlySetData(GetPublishableSeven()); SimpleBuffer bufferInit = SimpleBuffer.readFromFile(fileNameInit); IPublishableParser parserInit = platform.makePublishableParser(bufferInit.getReadIterator()); subs.applyStateSyncMessage(parserInit); SimpleBuffer buffer = SimpleBuffer.readFromFile(fileName); IPublishableParser parser = platform.makePublishableParser(buffer.getReadIterator()); subs.applyMessageWithUpdates(parser); //mtest.publishable_seven actual = (mtest.publishable_seven)subs.debugOnlyGetData(); mtest.publishable_seven expected = GetPublishableSeven(); Assert.False(expected.isEquivalent(subs)); updateDelegate(expected); Assert.True(expected.isEquivalent(subs)); }
static void TestJsonParseUpdate(String fileInitial, String fileUpdate, Events[] events) { List <Events> handled = new List <Events>(); publishable_seven_stub stub = new publishable_seven_stub(handled); SimpleBuffer bufferInitial = SimpleBuffer.readFromFile(fileInitial); JsonPublishableParser parserInitial = new JsonPublishableParser(bufferInitial.getReadIterator()); stub.applyStateSyncMessage(parserInitial); mtest.publishable_seven expected = test_publishable_seven.GetPublishableSeven(); Assert.True(expected.isEquivalent(stub)); if (fileUpdate != null) { SimpleBuffer bufferUpdate = SimpleBuffer.readFromFile(fileUpdate); JsonPublishableParser parserUpdate = new JsonPublishableParser(bufferUpdate.getReadIterator()); stub.applyMessageWithUpdates(parserUpdate); } Assert.AreEqual(events, handled.ToArray()); }
static void TestComposeUpdate(ITestPlatformSupport platform, String fileName, Action <mtest.Ipublishable_seven> updateDelegate) { mtest.publishable_seven_publisher publ = new mtest.publishable_seven_publisher(); mtest.publishable_seven data = GetPublishableSeven(); publ.debugOnlySetData(data); SimpleBuffer buffer = new SimpleBuffer(); IPublishableComposer composer = platform.makePublishableComposer(buffer); publ.startTick(composer); updateDelegate(publ); publ.endTick(); if (WriteFiles) { buffer.writeToFile(fileName); } SimpleBuffer expected = SimpleBuffer.readFromFile(fileName); Assert.True(platform.AreEqual(expected, buffer)); }