Exemplo n.º 1
0
        internal static void TestParseUpdate(ITestPlatformSupport platform, String fileNameInit, String fileName, Action <mtest.IStructSix> updateDelegate)
        {
            mtest.StructSix_subscriber subs = new  mtest.StructSix_subscriber();
            //subs.debugOnlySetData(GetPublishableSix());
            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.StructSix actual = ( mtest.StructSix)subs.debugOnlyGetData();
            mtest.StructSix expected = GetPublishableSix();

            if (updateDelegate != null)
            {
                // not equal yet
                Assert.False(subs.isEquivalent(expected));

                updateDelegate(expected);
            }

            Assert.True(subs.isEquivalent(expected));
        }
        public static void TestGmQueueWithStructSix()
        {
            MwsrThreadQueue msgQueue = new MwsrThreadQueue(5);
            MetaPool        mp       = initializeGmQueue(msgQueue);

            mtest.StructSix_publisher publ = new mtest.StructSix_publisher();

            mtest.StructSix data = test_publishable_six.GetPublishableSix();
            publ.debugOnlySetData(data);

            mp.add(publ);

            string path = getSubscriptionAddress("StructSix");

            mtest.StructSix_subscriber subs1 = new mtest.StructSix_subscriber();

            Assert.False(publ.isEquivalent(subs1));

            mp.add(subs1);
            mp.subscribe(subs1, path);

            int msgCnt = 0;

            mp.postAllUpdates();
            deliverAllMessages(mp, msgQueue, null, ref msgCnt);

            Assert.True(publ.isEquivalent(subs1));

            mtest.StructSix_subscriber subs2 = new mtest.StructSix_subscriber();
            //mtest.StructSix data2 = (mtest.StructSix)subs2.debugOnlyGetData();

            mp.add(subs2);
            mp.subscribe(subs2, path);

            mtest.StructSix_subscriber subs3 = new mtest.StructSix_subscriber();
            //mtest.StructSix data3 = (mtest.StructSix)subs3.debugOnlyGetData();

            mp.add(subs3);
            mp.subscribe(subs3, path);

            mp.postAllUpdates();
            deliverAllMessages(mp, msgQueue, null, ref msgCnt);

            Assert.True(publ.isEquivalent(subs2));
            Assert.True(publ.isEquivalent(subs3));

            test_publishable_six.doUpdate1(publ);

            Assert.False(publ.isEquivalent(subs1));
            Assert.False(publ.isEquivalent(subs2));
            Assert.False(publ.isEquivalent(subs3));

            mp.postAllUpdates();
            deliverAllMessages(mp, msgQueue, null, ref msgCnt);

            Assert.True(publ.isEquivalent(subs1));
            Assert.True(publ.isEquivalent(subs2));
            Assert.True(publ.isEquivalent(subs3));
        }
Exemplo n.º 3
0
        internal static void TestComposeStateSync(ITestPlatformSupport platform, String fileName)
        {
            mtest.StructSix_publisher publ = new  mtest.StructSix_publisher();
            mtest.StructSix           data = GetPublishableSix();
            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));
        }
Exemplo n.º 4
0
        internal static mtest.StructSix GetPublishableSix()
        {
            mtest.StructSix data = new  mtest.StructSix();

            data.name = "TheName";

            data.basic         = new  mtest.BasicTypes();
            data.basic.anInt   = -100000;
            data.basic.anUInt  = 100000;
            data.basic.aReal   = 3.14;
            data.basic.aString = "basic string";

            data.aggregate      = new  mtest.AggregateType();
            data.aggregate.name = "aggregate name";

            data.aggregate.theAggregate         = new  mtest.BasicTypes();
            data.aggregate.theAggregate.anInt   = -100;
            data.aggregate.theAggregate.anUInt  = 100;
            data.aggregate.theAggregate.aReal   = 100;
            data.aggregate.theAggregate.aString = "basic string inside aggregate";
            data.aggregate.lastValue            = 0;

            return(data);
        }
Exemplo n.º 5
0
        internal static void TestComposeUpdate(ITestPlatformSupport platform, String fileName, Action <mtest.IStructSix> updateDelegate)
        {
            mtest.StructSix_publisher publ = new mtest.StructSix_publisher();
            mtest.StructSix           data = GetPublishableSix();
            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));
        }