示例#1
0
        public void GetAllDecoratorsGenericTypes_OneDecorator_ReturnsIt()
        {
            // arrange
            var container = new Container {
                Options = { AllowOverridingRegistrations = true }
            };
            var lifestyle = Lifestyle.Transient;

            CommandsLibrary.Setup(container, lifestyle);
            CommandsLibrary.RegisterCommandsDecorator(typeof(TestDecorator <,>), container, lifestyle);


            // act
            var result = CommandsLibrary.CommandsProcessor.GetAllDecoratorsGenericTypes <TestDecoratableCommand> ();


            // assert
            result.Should().Equal(typeof(TestDecorator <,>));
        }
示例#2
0
        public void RegisterCommandsDecorator_TwoRegistrations_Singleton_Verifies()
        {
            // arrange
            var container = new Container {
                Options = { AllowOverridingRegistrations = true }
            };
            var lifestyle = Lifestyle.Transient;

            CommandsLibrary.Setup(container, lifestyle);
            CommandsLibrary.RegisterCommandsDecorator(typeof(TestSingletonDecorator <,>), container, Lifestyle.Singleton);
            CommandsLibrary.RegisterCommandsDecorator(typeof(TestSingletonDecorator <,>), container, Lifestyle.Singleton);


            // act
            Action act = () => container.Verify();


            // assert
            act.Should().NotThrow();
        }
示例#3
0
        public void RegisterCommandsDecorator_DoesNotAppliesDecoratorToNotApplicableCommands()
        {
            // arrange
            var container = new Container {
                Options = { AllowOverridingRegistrations = true }
            };
            var lifestyle = Lifestyle.Transient;

            CommandsLibrary.Setup(container, lifestyle);
            CommandsLibrary.RegisterCommandsDecorator(typeof(TestDecorator <,>), container, lifestyle);

            var command = new TestNotDecoratableCommand {
                Number = 1
            };


            // act
            var result = CommandsLibrary.CommandsProcessor.Execute(command);


            // assert
            command.Number.Should().Be(2);
            result.Should().Be(2);
        }