Example #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));
        }
Example #3
0
 public void UsingInitialImplType_executes_appropriate_functionality_from_wrapped_service([Frozen] ICreatesAutofacDecorator <IServiceInterface> wrapped,
                                                                                          GenericDecoratorBuilderAdapter <IServiceInterface> sut,
                                                                                          Type aType,
                                                                                          ICustomizesAutofacDecorator <IServiceInterface> customiser)
 {
     Mock.Get(wrapped)
     .Setup(x => x.UsingInitialImplType(It.IsAny <Type>(), It.IsAny <Parameter[]>()))
     .Returns(customiser);
     sut.UsingInitialImplType(aType);
     Mock.Get(wrapped).Verify(x => x.UsingInitialImplType(aType), Times.Once);
 }
 public void ThenWrapWithType_executes_appropriate_functionality_from_wrapped_service([Frozen] ICustomizesAutofacDecorator wrapped,
                                                                                      DecoratorCustomizerAdapter sut,
                                                                                      Type aType,
                                                                                      ICustomizesAutofacDecorator customiser)
 {
     Mock.Get(wrapped)
     .Setup(x => x.ThenWrapWithType(It.IsAny <Type>(), It.IsAny <Parameter[]>()))
     .Returns(customiser);
     sut.ThenWrapWithType(aType);
     Mock.Get(wrapped).Verify(x => x.ThenWrapWithType(aType), Times.Once);
 }
 public void ThenWrapWith_executes_appropriate_functionality_from_wrapped_service([Frozen] ICustomizesAutofacDecorator <IServiceInterface> wrapped,
                                                                                  GenericDecoratorCustomizerAdapter <IServiceInterface> sut,
                                                                                  ICustomizesAutofacDecorator <IServiceInterface> customiser)
 {
     Mock.Get(wrapped)
     .Setup(x => x.ThenWrapWith <ServiceImpl1>(It.IsAny <Parameter[]>()))
     .Returns(customiser);
     sut.ThenWrapWith <ServiceImpl1>();
     Mock.Get(wrapped).Verify(x => x.ThenWrapWith <ServiceImpl1>(), Times.Once);
 }
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="DecoratorCustomizerAdapter"/> class.
 /// </summary>
 /// <param name="customizer">A wrapped autofac-specific decorator-customizer.</param>
 public DecoratorCustomizerAdapter(ICustomizesAutofacDecorator customizer)
 {
     builder = customizer ?? throw new ArgumentNullException(nameof(customizer));
 }