public void LayerStack_OnSend_InvokesForwardOrder()
        {
            var         testList      = new List <string>();
            var         testLayer1    = new TestLayer_Append("foo", testList);
            var         testLayer2    = new TestLayer_Append("bar", testList);
            var         stackProvider = new LayerStackProvider <Dummy>(testLayer1, testLayer2);
            Logger      logger        = LoggerTests.BlackHole;
            ILayerStack stack;
            Error       error = stackProvider.GetLayerStack(null, out stack, logger);

            Assert.IsNull(error);

            IBonded layerData;

            error = stack.OnSend(MessageType.REQUEST, sendContext, out layerData, logger);

            Assert.IsNull(error);
            Assert.IsNotNull(layerData);

            Dummy realLayerData = layerData.Deserialize <Dummy>();

            Assert.AreEqual(2, testList.Count);
            Assert.AreEqual(testLayer1.value, testList[0]);
            Assert.AreEqual(testLayer1.value + testLayer2.value, testList[1]);
            Assert.IsNotNull(realLayerData);
            Assert.AreEqual(testLayer1.value + testLayer2.value, realLayerData.string_value);
        }
예제 #2
0
        public void LayerStack_OnReceive_InvokesReverseOrder()
        {
            var testList   = new List <string>();
            var testLayer1 = new TestLayer_Append("foo", testList);
            var testLayer2 = new TestLayer_Append("bar", testList);
            var stack      = new LayerStack <Dummy>(testLayer1, testLayer2);

            Error error = stack.OnReceive(MessageType.Request, receiveContext, CreateBondedTestData(initialReceiveValue));

            Assert.IsNull(error);
            Assert.AreEqual(2, testList.Count);
            Assert.AreEqual(initialReceiveValue + testLayer2.value, testList[0]);
            Assert.AreEqual(initialReceiveValue + testLayer2.value + testLayer1.value, testList[1]);
        }
예제 #3
0
        public void LayerStack_OnReceive_InvokesReverseOrder()
        {
            var         testList      = new List <string>();
            var         testLayer1    = new TestLayer_Append("foo", testList);
            var         testLayer2    = new TestLayer_Append("bar", testList);
            var         stackProvider = new LayerStackProvider <Dummy>(LoggerTests.BlackHole, testLayer1, testLayer2);
            ILayerStack stack;
            Error       error = stackProvider.GetLayerStack(null, out stack);

            Assert.IsNull(error);

            error = stack.OnReceive(MessageType.REQUEST, receiveContext, CreateBondedTestData(initialReceiveValue));

            Assert.IsNull(error);
            Assert.AreEqual(2, testList.Count);
            Assert.AreEqual(initialReceiveValue + testLayer2.value, testList[0]);
            Assert.AreEqual(initialReceiveValue + testLayer2.value + testLayer1.value, testList[1]);
        }
예제 #4
0
        public void LayerStack_OnSend_InvokesForwardOrder()
        {
            var testList   = new List <string>();
            var testLayer1 = new TestLayer_Append("foo", testList);
            var testLayer2 = new TestLayer_Append("bar", testList);
            var stack      = new LayerStack <Dummy>(testLayer1, testLayer2);

            IBonded layerData;
            Error   error = stack.OnSend(MessageType.Request, sendContext, out layerData);

            Assert.IsNull(error);
            Assert.IsNotNull(layerData);

            Dummy realLayerData = layerData.Deserialize <Dummy>();

            Assert.AreEqual(2, testList.Count);
            Assert.AreEqual(testLayer1.value, testList[0]);
            Assert.AreEqual(testLayer1.value + testLayer2.value, testList[1]);
            Assert.IsNotNull(realLayerData);
            Assert.AreEqual(testLayer1.value + testLayer2.value, realLayerData.string_value);
        }