CodeValue.CodeCommander.Tests.CommandProcessorTests.InputSource_CommandFailsDueToInput_CommandIsFailed C# (CSharp) Méthode

InputSource_CommandFailsDueToInput_CommandIsFailed() private méthode

private InputSource_CommandFailsDueToInput_CommandIsFailed ( ) : void
Résultat void
        public void InputSource_CommandFailsDueToInput_CommandIsFailed()
        {
            var commandFailed = false;
            var inputSource = new Subject<ProcessorInput>();
            var resetEvent = new ManualResetEventSlim(false);
            Exception thrownedException = null;
            var exceptionMessage = "Test";

            var fakeFilterManager = A.Fake<IFilterManager>();
            A.CallTo(() => fakeFilterManager.Process(A<CommandBase>.Ignored)).Returns(true);
            var processor = new CommandProcessor(inputSource, fakeFilterManager);
            var command = new TestCommand(CommandState.New, interpretResponseAction: i =>
            {
                throw new Exception(exceptionMessage);
            });

            command.RegisterForStateChange(Observer.Create<CommandState>(b =>
            {
                if (b == CommandState.Executing)
                {
                    resetEvent.Set();
                }
            }));

            processor.PublishCommand(command, Observer.Create<ICommandResponse<Unit>>(_ => { }, ex =>
                                                                                                {
                                                                                                    thrownedException =
                                                                                                        ex;
                                                                                                    commandFailed = true;
                                                                                                    resetEvent.Set();

                                                                                                }));

            resetEvent.Wait();

            inputSource.OnNext(new ProcessorInput());

            resetEvent.Wait();

            Assert.IsTrue(commandFailed);
            Assert.AreEqual(thrownedException.Message, exceptionMessage);
        }
CommandProcessorTests