コード例 #1
0
        public void AppendHandler_UsingType_AddsSequentially()
        {
            // Arrange
            var factoryMock = Substitute.For <IApiHttpHandlerFactory>();
            var binding     = new ApiHttpRequestHandlerBinding(factoryMock, typeof(ApiHttpRequestHandlerMock));

            var handler1 = typeof(ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType1Mock);
            var handler2 = typeof(ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType2Mock);
            var handler3 = typeof(ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType3Mock);
            var handler4 = typeof(ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType4Mock);
            var handler5 = typeof(ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType5Mock);

            // Act
            binding.AppendHandler(handler1);
            binding.AppendHandler(handler2);
            binding.AppendHandler(handler3);
            binding.AppendHandler(handler4);
            binding.AppendHandler(handler5);

            // Assert
            Assert.Equal(5, binding.Bindings.Count);
            Assert.Equal(handler1, binding.Bindings[0].HandlerType);
            Assert.Equal(handler2, binding.Bindings[1].HandlerType);
            Assert.Equal(handler3, binding.Bindings[2].HandlerType);
            Assert.Equal(handler4, binding.Bindings[3].HandlerType);
            Assert.Equal(handler5, binding.Bindings[4].HandlerType);
        }
コード例 #2
0
        public void AppendHandler_UsingGeneric_AddsSequentially()
        {
            // Arrange
            var factoryMock = Substitute.For <IApiHttpHandlerFactory>();

            var binding = new ApiHttpRequestHandlerBinding(factoryMock, typeof(ApiHttpRequestHandlerMock));

            // Act
            binding.AppendHandler <ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType1Mock>();
            binding.AppendHandler <ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType2Mock>();
            binding.AppendHandler <ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType3Mock>();
            binding.AppendHandler <ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType4Mock>();
            binding.AppendHandler <ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType5Mock>();

            // Assert
            Assert.Equal(5, binding.Bindings.Count);
            Assert.Equal(typeof(ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType1Mock), binding.Bindings[0].HandlerType);
            Assert.Equal(typeof(ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType2Mock), binding.Bindings[1].HandlerType);
            Assert.Equal(typeof(ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType3Mock), binding.Bindings[2].HandlerType);
            Assert.Equal(typeof(ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType4Mock), binding.Bindings[3].HandlerType);
            Assert.Equal(typeof(ApiHttpRequestHandlerMock.ApiHttpRequestHandlerDifferentType5Mock), binding.Bindings[4].HandlerType);
        }