public async Task MethodCall_Event_FailingLayerStackProvider_ServerReceiveEvent()
        {
            // Fail after 3 successful GetLayerStack calls (2 on client, 1 on server)
            transportBuilder.SetLayerStackProvider(new TestLayerStackProvider_Fails(3));
            var testService = new DummyTestService();

            await DefaultSetup(testService, 1);

            var proxy    = new DummyTestProxy <SimpleInMemConnection>(connections[0]);
            var theEvent = new Dummy {
                int_value = 100
            };

            ManualResetEventSlim waitForEvent = testService.CreateResetEvent();

            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));

            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(1, testService.EventCount);
            Assert.AreEqual(theEvent.int_value, testService.LastEventReceived.int_value);

            waitForEvent = testService.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsFalse(wasSignaled, "Event should not fire 2");

            Assert.AreEqual(1, testService.EventCount);
        }
Beispiel #2
0
        public async Task GeneratedService_GeneratedProxy_Event_ServerLayerErrors()
        {
            var errorLayer = new TestLayer_ReturnErrors();
            var serverLayerStackProvider = new LayerStackProvider <Dummy>(errorLayer);
            TestClientServer <DummyTestService> testClientServer = await SetupTestClientServer <DummyTestService>(serverLayerStackProvider, null);

            var proxy    = new DummyTestProxy <EpoxyConnection>(testClientServer.ClientConnection);
            var theEvent = new Dummy {
                int_value = 100
            };

            errorLayer.SetState(MessageType.EVENT, errorOnSend: false, errorOnReceive: true);

            ManualResetEventSlim waitForEvent = testClientServer.Service.CreateResetEvent();

            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));

            Assert.IsFalse(wasSignaled, "Event should not fire");
            testClientServer.Service.ClearResetEvent();

            Assert.AreEqual(0, testClientServer.Service.EventCount);
            Assert.AreEqual(Dummy.Empty.int_value, testClientServer.Service.LastEventReceived.int_value);

            errorLayer.SetState(MessageType.EVENT, errorOnSend: true, errorOnReceive: false);
            theEvent.int_value = 101;

            waitForEvent = testClientServer.Service.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(1, testClientServer.Service.EventCount);
            Assert.AreEqual(theEvent.int_value, testClientServer.Service.LastEventReceived.int_value);
        }
Beispiel #3
0
        public async Task GeneratedService_GeneratedProxy_Event_StatefulLayers()
        {
            var clientLayerProvider      = new TestLayerProvider_StatefulAppend("Client");
            var clientLayerStackProvider = new LayerStackProvider <Dummy>(LoggerTests.BlackHole, clientLayerProvider);
            var serverLayerProvider      = new TestLayerProvider_StatefulAppend("Server");
            var serverLayerStackProvider = new LayerStackProvider <Dummy>(LoggerTests.BlackHole, serverLayerProvider);
            TestClientServer <DummyTestService> testClientServer =
                await SetupTestClientServer <DummyTestService>(serverLayerStackProvider, clientLayerStackProvider);

            var proxy    = new DummyTestProxy <EpoxyConnection>(testClientServer.ClientConnection);
            var theEvent = new Dummy {
                int_value = 100
            };

            clientLayerProvider.Layers.Clear();
            serverLayerProvider.Layers.Clear();

            ManualResetEventSlim waitForEvent = testClientServer.Service.CreateResetEvent();

            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));

            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(1, testClientServer.Service.EventCount);
            Assert.AreEqual(theEvent.int_value, testClientServer.Service.LastEventReceived.int_value);

            Assert.AreEqual(1, clientLayerProvider.Layers.Count);
            Assert.AreEqual(1, serverLayerProvider.Layers.Count);
            Assert.AreEqual("Client0Send", clientLayerProvider.Layers[0].State);
            Assert.AreEqual("Server0Receive", serverLayerProvider.Layers[0].State);

            theEvent.int_value = 101;

            waitForEvent = testClientServer.Service.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(2, testClientServer.Service.EventCount);
            Assert.AreEqual(theEvent.int_value, testClientServer.Service.LastEventReceived.int_value);

            Assert.AreEqual(2, clientLayerProvider.Layers.Count);
            Assert.AreEqual(2, serverLayerProvider.Layers.Count);
            Assert.AreEqual("Client1Send", clientLayerProvider.Layers[1].State);
            Assert.AreEqual("Server1Receive", serverLayerProvider.Layers[1].State);

            await testClientServer.ServiceTransport.StopAsync();

            await testClientServer.ClientTransport.StopAsync();
        }
        public async Task MethodCall_Event_WithLayerStackErrors()
        {
            var errorLayer = new TestLayer_ReturnErrors();

            transportBuilder.SetLayerStackProvider(new LayerStackProvider <Dummy>(errorLayer));
            var testService = new DummyTestService();

            await DefaultSetup(testService, 1);

            var proxy    = new DummyTestProxy <SimpleInMemConnection>(connections[0]);
            var theEvent = new Dummy {
                int_value = 100
            };

            errorLayer.SetState(MessageType.EVENT, errorOnSend: false, errorOnReceive: true);

            ManualResetEventSlim waitForEvent = testService.CreateResetEvent();

            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));

            Assert.IsFalse(wasSignaled, "Event should not fire 1");
            testService.ClearResetEvent();

            Assert.AreEqual(0, testService.EventCount);
            Assert.AreEqual(Dummy.Empty.int_value, testService.LastEventReceived.int_value);

            errorLayer.SetState(MessageType.EVENT, errorOnSend: true, errorOnReceive: false);
            theEvent.int_value = 101;

            waitForEvent = testService.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsFalse(wasSignaled, "Event should not fire 2");
            testService.ClearResetEvent();

            Assert.AreEqual(0, testService.EventCount);
            Assert.AreEqual(Dummy.Empty.int_value, testService.LastEventReceived.int_value);

            errorLayer.SetState(MessageType.EVENT, errorOnSend: false, errorOnReceive: false);
            theEvent.int_value = 102;

            waitForEvent = testService.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(1, testService.EventCount);
            Assert.AreEqual(theEvent.int_value, testService.LastEventReceived.int_value);
        }
        public async Task MethodCall_Event_With_StatefulLayers()
        {
            var layerProvider      = new TestLayerProvider_StatefulAppend("Layer");
            var layerStackProvider = new LayerStackProvider <Dummy>(layerProvider);

            transportBuilder.SetLayerStackProvider(layerStackProvider);
            var testService = new DummyTestService();

            await DefaultSetup(testService, 1);

            var proxy    = new DummyTestProxy <SimpleInMemConnection>(connections[0]);
            var theEvent = new Dummy {
                int_value = 100
            };

            layerProvider.Layers.Clear();

            ManualResetEventSlim waitForEvent = testService.CreateResetEvent();

            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));

            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");
            testService.ClearResetEvent();

            Assert.AreEqual(1, testService.EventCount);
            Assert.AreEqual(theEvent.int_value, testService.LastEventReceived.int_value);

            Assert.AreEqual(2, layerProvider.Layers.Count);
            Assert.AreEqual("Layer0Send", layerProvider.Layers[0].State);
            Assert.AreEqual("Layer1Receive", layerProvider.Layers[1].State);
        }
Beispiel #6
0
        public async Task GeneratedService_GeneratedProxy_Event()
        {
            TestClientServer <DummyTestService> testClientServer = await SetupTestClientServer <DummyTestService>();

            var proxy    = new DummyTestProxy <EpoxyConnection>(testClientServer.ClientConnection);
            var theEvent = new Dummy {
                int_value = 100
            };

            ManualResetEventSlim waitForEvent = testClientServer.Service.CreateResetEvent();

            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(5));

            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(0, testClientServer.Service.RequestCount);
            Assert.AreEqual(1, testClientServer.Service.EventCount);
            Assert.AreEqual(theEvent.int_value, testClientServer.Service.LastEventReceived.int_value);
        }
        public async Task MethodCall_Event_FailingLayerStackProvider_ServerReceiveEvent()
        {
            // Fail after 3 successful GetLayerStack calls (2 on client, 1 on server)
            transportBuilder.SetLayerStackProvider(new TestLayerStackProvider_Fails(3));
            var testService = new DummyTestService();
            await DefaultSetup(testService, 1);

            var proxy = new DummyTestProxy<SimpleInMemConnection>(connections[0]);
            var theEvent = new Dummy { int_value = 100 };

            ManualResetEventSlim waitForEvent = testService.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(1, testService.EventCount);
            Assert.AreEqual(theEvent.int_value, testService.LastEventReceived.int_value);

            waitForEvent = testService.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsFalse(wasSignaled, "Event should not fire 2");

            Assert.AreEqual(1, testService.EventCount);
        }
        public async Task MethodCall_Event_WithLayerStackErrors()
        {
            var errorLayer = new TestLayer_ReturnErrors();
            transportBuilder.SetLayerStackProvider(new LayerStackProvider<Dummy>(LoggerTests.BlackHole, errorLayer));
            var testService = new DummyTestService();
            await DefaultSetup(testService, 1);

            var proxy = new DummyTestProxy<SimpleInMemConnection>(connections[0]);
            var theEvent = new Dummy { int_value = 100 };

            errorLayer.SetState(MessageType.Event, errorOnSend: false, errorOnReceive: true);

            ManualResetEventSlim waitForEvent = testService.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsFalse(wasSignaled, "Event should not fire 1");
            testService.ClearResetEvent();

            Assert.AreEqual(0, testService.EventCount);
            Assert.AreEqual(Dummy.Empty.int_value, testService.LastEventReceived.int_value);

            errorLayer.SetState(MessageType.Event, errorOnSend: true, errorOnReceive: false);
            theEvent.int_value = 101;

            waitForEvent = testService.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsFalse(wasSignaled, "Event should not fire 2");
            testService.ClearResetEvent();

            Assert.AreEqual(0, testService.EventCount);
            Assert.AreEqual(Dummy.Empty.int_value, testService.LastEventReceived.int_value);

            errorLayer.SetState(MessageType.Event, errorOnSend: false, errorOnReceive: false);
            theEvent.int_value = 102;

            waitForEvent = testService.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(1, testService.EventCount);
            Assert.AreEqual(theEvent.int_value, testService.LastEventReceived.int_value);
        }
        public async Task MethodCall_Event_With_StatefulLayers()
        {
            var layerProvider = new TestLayerProvider_StatefulAppend("Layer");
            var layerStackProvider = new LayerStackProvider<Dummy>(LoggerTests.BlackHole, layerProvider);
            transportBuilder.SetLayerStackProvider(layerStackProvider);
            var testService = new DummyTestService();
            await DefaultSetup(testService, 1);

            var proxy = new DummyTestProxy<SimpleInMemConnection>(connections[0]);
            var theEvent = new Dummy { int_value = 100 };

            layerProvider.Layers.Clear();

            ManualResetEventSlim waitForEvent = testService.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");
            testService.ClearResetEvent();

            Assert.AreEqual(1, testService.EventCount);
            Assert.AreEqual(theEvent.int_value, testService.LastEventReceived.int_value);

            Assert.AreEqual(2, layerProvider.Layers.Count);
            Assert.AreEqual("Layer0Send", layerProvider.Layers[0].State);
            Assert.AreEqual("Layer1Receive", layerProvider.Layers[1].State);
        }
Beispiel #10
0
        public async Task GeneratedService_GeneratedProxy_Event_StatefulLayers()
        {
            var clientLayerProvider = new TestLayerProvider_StatefulAppend("Client");
            var clientLayerStackProvider = new LayerStackProvider<Dummy>(LoggerTests.BlackHole, clientLayerProvider);
            var serverLayerProvider = new TestLayerProvider_StatefulAppend("Server");
            var serverLayerStackProvider = new LayerStackProvider<Dummy>(LoggerTests.BlackHole, serverLayerProvider);
            TestClientServer<DummyTestService> testClientServer =
                await SetupTestClientServer<DummyTestService>(serverLayerStackProvider, clientLayerStackProvider);
            var proxy = new DummyTestProxy<EpoxyConnection>(testClientServer.ClientConnection);
            var theEvent = new Dummy { int_value = 100 };

            clientLayerProvider.Layers.Clear();
            serverLayerProvider.Layers.Clear();

            ManualResetEventSlim waitForEvent = testClientServer.Service.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(1, testClientServer.Service.EventCount);
            Assert.AreEqual(theEvent.int_value, testClientServer.Service.LastEventReceived.int_value);

            Assert.AreEqual(1, clientLayerProvider.Layers.Count);
            Assert.AreEqual(1, serverLayerProvider.Layers.Count);
            Assert.AreEqual("Client0Send", clientLayerProvider.Layers[0].State);
            Assert.AreEqual("Server0Receive", serverLayerProvider.Layers[0].State);

            theEvent.int_value = 101;

            waitForEvent = testClientServer.Service.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(2, testClientServer.Service.EventCount);
            Assert.AreEqual(theEvent.int_value, testClientServer.Service.LastEventReceived.int_value);

            Assert.AreEqual(2, clientLayerProvider.Layers.Count);
            Assert.AreEqual(2, serverLayerProvider.Layers.Count);
            Assert.AreEqual("Client1Send", clientLayerProvider.Layers[1].State);
            Assert.AreEqual("Server1Receive", serverLayerProvider.Layers[1].State);

            await testClientServer.ServiceTransport.StopAsync();
            await testClientServer.ClientTransport.StopAsync();
        }
Beispiel #11
0
        public async Task GeneratedService_GeneratedProxy_Event_ServerLayerErrors()
        {
            var errorLayer = new TestLayer_ReturnErrors();
            var serverLayerStackProvider = new LayerStackProvider<Dummy>(LoggerTests.BlackHole, errorLayer);
            TestClientServer<DummyTestService> testClientServer = await SetupTestClientServer<DummyTestService>(serverLayerStackProvider, null);
            var proxy = new DummyTestProxy<EpoxyConnection>(testClientServer.ClientConnection);
            var theEvent = new Dummy { int_value = 100 };

            errorLayer.SetState(MessageType.EVENT, errorOnSend: false, errorOnReceive: true);

            ManualResetEventSlim waitForEvent = testClientServer.Service.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsFalse(wasSignaled, "Event should not fire");
            testClientServer.Service.ClearResetEvent();

            Assert.AreEqual(0, testClientServer.Service.EventCount);
            Assert.AreEqual(Dummy.Empty.int_value, testClientServer.Service.LastEventReceived.int_value);

            errorLayer.SetState(MessageType.EVENT, errorOnSend: true, errorOnReceive: false);
            theEvent.int_value = 101;

            waitForEvent = testClientServer.Service.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(1));
            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(1, testClientServer.Service.EventCount);
            Assert.AreEqual(theEvent.int_value, testClientServer.Service.LastEventReceived.int_value);

            await testClientServer.ServiceTransport.StopAsync();
            await testClientServer.ClientTransport.StopAsync();
        }
Beispiel #12
0
        public async Task GeneratedService_GeneratedProxy_Event()
        {
            TestClientServer<DummyTestService> testClientServer = await SetupTestClientServer<DummyTestService>();
            var proxy = new DummyTestProxy<EpoxyConnection>(testClientServer.ClientConnection);
            var theEvent = new Dummy { int_value = 100 };

            ManualResetEventSlim waitForEvent = testClientServer.Service.CreateResetEvent();
            proxy.EventMethodAsync(theEvent);
            bool wasSignaled = waitForEvent.Wait(TimeSpan.FromSeconds(5));
            Assert.IsTrue(wasSignaled, "Timed out waiting for event to fire");

            Assert.AreEqual(0, testClientServer.Service.RequestCount);
            Assert.AreEqual(1, testClientServer.Service.EventCount);
            Assert.AreEqual(theEvent.int_value, testClientServer.Service.LastEventReceived.int_value);

            await testClientServer.ServiceTransport.StopAsync();
            await testClientServer.ClientTransport.StopAsync();
         }