public void SimpleInterfaceBasedRoutingShouldWork()
        {
            var processor    = Substitute.For <IMessageHandler <SomeDto> >();
            var router       = RoutingTestEnvironment.GetInterfaceBasedRoutingProvider(processor);
            var routedObject = RoutingTestEnvironment.GetTestDtoData();

            router.RouteObject(null, routedObject);
            processor.Received().HandleMessage(routedObject);
        }
示例#2
0
        public void StaticWithInterfaceRoutingBothShouldWorkInOrder()
        {
            var xProcessor = Substitute.For <IXProcessor>();

            var router = RoutingTestEnvironment.GetStaticRoutingWithInterfaceRoutingProvider(xProcessor);

            router.RouteObject(string.Empty);
            xProcessor.Received(1).OnString(string.Empty);
            xProcessor.Received(1).HandleMessage(string.Empty);
        }
        public void AsyncHandlingWithContextShouldWork()
        {
            var processor = new SomeProcessor();
            var router    = RoutingTestEnvironment.GetInterfaceBasedRoutingProvider(processor);

            Func <Task> f           = async() => { await router.RouteObjectAsync(processor, string.Empty); };
            var         throwResult = f.Should().Throw <AggregateException>();

            throwResult.WithInnerException <SomeRoutingException>();
        }
示例#4
0
        public void DirectInterfaceMethodCallShouldWork()
        {
            //Arrange
            var processor       = Substitute.For <ISomeSessionProcessor>();
            var routingProvider = RoutingTestEnvironment.GetStaticNamesRoutingProvider(processor);

            //Act
            routingProvider.RouteCall <ISomeSessionProcessor>(
                sessionProcessor => { sessionProcessor.OnSessionClosed(); });

            //Assert
            processor.Received().OnSessionClosed();
        }
示例#5
0
        public void SimplestStaticRoutingCallShouldWork()
        {
            //Arrange
            var processor       = Substitute.For <ISomeApiProcessor>();
            var routingProvider = RoutingTestEnvironment.GetStaticNamesRoutingProvider(processor);
            var dto             = RoutingTestEnvironment.GetTestDtoData();

            //Act
            routingProvider.RouteObject(new object(), dto);


            //Assert
            processor.Received().OnSomeDto(dto);
        }
示例#6
0
        public void RoutingObjectShouldBeForAllProcessorsByDefault()
        {
            //Arrange
            var processor       = Substitute.For <ISomeApiProcessor>();
            var processor2      = Substitute.For <ISomeApiProcessor>();
            var routingProvider = RoutingTestEnvironment.GetStaticNamesRoutingProvider(processor, processor2);

            var dto = RoutingTestEnvironment.GetTestDtoData();

            //Act
            routingProvider.RouteObject(new object(), dto);

            //Assert
            processor.Received().OnSomeDto(dto);
            processor2.Received().OnSomeDto(dto);
        }
        public void SimpleInterfaceRoutingWithContextShouldWork2()
        {
            var processor    = Substitute.For <ComplexInterface>();
            var router       = RoutingTestEnvironment.GetInterfaceBasedRoutingProvider(processor);
            var routedObject = RoutingTestEnvironment.GetTestDtoData();
            var context      = new SomeContext();

            router.RouteObject(context, routedObject);

            processor.Received().HandleMessage(context, routedObject);
            processor.Received().HandleMessage(routedObject);


            processor.DidNotReceive().HandleMessage(routedObject, routedObject);
            processor.DidNotReceive().HandleMessage(routedObject, context);
            processor.DidNotReceive().HandleMessage(context, context);
        }