コード例 #1
0
ファイル: Tests.cs プロジェクト: kukuRUSik/Rocks.Commands
        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
ファイル: Tests.cs プロジェクト: kukuRUSik/Rocks.Commands
        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
ファイル: Tests.cs プロジェクト: kukuRUSik/Rocks.Commands
        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);
        }