예제 #1
0
        public void UsingInitialImpl_maps_and_passes_parameters([Frozen] ICreatesAutofacDecorator <IServiceInterface> wrapped,
                                                                GenericDecoratorBuilderAdapter <IServiceInterface> sut,
                                                                ICustomizesAutofacDecorator <IServiceInterface> customiser)
        {
            Parameter[] parameters = null;
            Mock.Get(wrapped)
            .Setup(x => x.UsingInitialImpl <ServiceImpl1>(It.IsAny <Parameter[]>()))
            .Callback((Parameter[] @params) => parameters = @params)
            .Returns(customiser);
            sut.UsingInitialImpl <ServiceImpl1>(TypedParam.From("Foo bar"), TypedParam.From(5));

            IEqualityComparer <Parameter> comparer = new TypedParameterComparer();
            var expected = new[]
            {
                TypedParameter.From("Foo bar"),
                TypedParameter.From(5),
            };

            Assert.That(parameters, Is.EqualTo(expected).Using(comparer));
        }
        public void ThenWrapWith_maps_and_passes_parameters([Frozen] ICustomizesAutofacDecorator wrapped,
                                                            DecoratorCustomizerAdapter sut,
                                                            ICustomizesAutofacDecorator customiser)
        {
            Parameter[] parameters = null;
            Mock.Get(wrapped)
            .Setup(x => x.ThenWrapWith <ServiceImpl1>(It.IsAny <Parameter[]>()))
            .Callback((Parameter[] @params) => parameters = @params)
            .Returns(customiser);
            sut.ThenWrapWith <ServiceImpl1>(TypedParam.From("Foo bar"), TypedParam.From(5));

            IEqualityComparer <Parameter> comparer = new TypedParameterComparer();
            var expected = new[]
            {
                TypedParameter.From("Foo bar"),
                TypedParameter.From(5),
            };

            Assert.That(parameters, Is.EqualTo(expected).Using(comparer));
        }