static void TestComposeStateSync(Protocol proto, String fileName, Func <mtest.publishable_dictionary> getState)
        {
            mtest.publishable_dictionary_publisher publ = new mtest.publishable_dictionary_publisher();
            mtest.publishable_dictionary           data = getState();
            publ.debugOnlySetData(data);

            SimpleBuffer         buffer   = new SimpleBuffer();
            IPublishableComposer composer = makePublishableComposer(proto, buffer);

            publ.generateStateSyncMessage(composer);

            // uncomment to update file
            if (WriteFiles)
            {
                buffer.writeToFile(fileName);
            }

            SimpleBuffer expected = SimpleBuffer.readFromFile(fileName);

            if (proto == Protocol.Json)
            {
                Assert.True(SimpleBuffer.AreEqualIgnoreEol(expected, buffer));
            }
            else if (proto == Protocol.Gmq)
            {
                Assert.AreEqual(expected, buffer);
            }
        }
Пример #2
0
        static void TestComposeUpdate(TestCommon.Protocol proto, String fileName, Func <mtest.publishable_dictionary> getState, Action <mtest.Ipublishable_dictionary> updateDelegate)
        {
            mtest.publishable_dictionary_publisher publ = new mtest.publishable_dictionary_publisher();
            mtest.publishable_dictionary           data = getState();
            publ.debugOnlySetData(data);

            SimpleBuffer         buffer   = new SimpleBuffer();
            IPublishableComposer composer = TestCommon.makePublishableComposer(proto, buffer);

            publ.startTick(composer);

            updateDelegate(publ);

            publ.endTick();

            if (WriteFiles)
            {
                buffer.writeToFile(fileName);
            }

            SimpleBuffer expected = SimpleBuffer.readFromFile(fileName);

            if (proto == TestCommon.Protocol.Json)
            {
                Assert.True(SimpleBuffer.AreEqualIgnoreEol(expected, buffer));
            }
            else if (proto == TestCommon.Protocol.Gmq)
            {
                Assert.AreEqual(expected, buffer);
            }
        }
        static void TestComposeUpdate(Protocol proto, String fileName, Func <mtest.publishable_dictionary> getState, Action <mtest.Ipublishable_dictionary> updateDelegate)
        {
            mtest.publishable_dictionary_publisher publ = new mtest.publishable_dictionary_publisher();
            mtest.publishable_dictionary           data = getState();
            publ.debugOnlySetData(data);

            SimpleBuffer         buffer   = new SimpleBuffer();
            IPublishableComposer composer = makePublishableComposer(proto, buffer);

            publ.startTick(composer);

            updateDelegate(publ);

            publ.endTick();

            if (WriteFiles)
            {
                buffer.writeToFile(fileName);
            }

            Assert.AreEqual(buffer, SimpleBuffer.readFromFile(fileName));
        }