예제 #1
0
        public void multi_route_test()
        {
            // arrange
            var mockDefinition = new Mock<IPipeDefinition>();
            mockDefinition.SetupGet(e => e.Operations).Returns(new[]
                                                                   {
                                                                       new RoutedOper(
                                                                           (injector, input) => (int) input*100,
                                                                           (injector, input) => (int) input == 4),
                                                                       new RoutedOper(
                                                                           (injector, input) => (int) input*1000,
                                                                           (injector, input) => (int) input == 3),
                                                                       new Oper((injector, input) => (int) input*10)
                                                                   });
            mockDefinition.SetupGet(e => e.Closed).Returns(true);

            var compiler = new RouterCompiler(mockDefinition.Object);

            // act
            var fn = compiler.Compile();

            // assert
            Assert.That(GetRoutedValue(fn, 4), Is.EqualTo(400));
            Assert.That(GetRoutedValue(fn, 2), Is.EqualTo(20));
            Assert.That(GetRoutedValue(fn, 3), Is.EqualTo(3000));
        }
예제 #2
0
        public void verify_throws_on_unclosed_composition()
        {
            // arrange
            var mockDefinition = new Mock<IPipeDefinition>();
            mockDefinition.SetupGet(e => e.Closed).Returns(false);
            var compiler = new RouterCompiler(mockDefinition.Object);

            // act & assert
            Assert.Throws<MismatchedClosingTypeDeclarationException>( () =>  compiler.Compile());
        }