public void CommandPublish_CommandThrowsExceptionWhileExecuting_CommandFailsWithThatException()
{
bool wasThrown = false;
Exception thrownException = new Exception("Text");
Exception expectedException = null;
var resetEvent = new ManualResetEventSlim(false);
var fakeFilterManager = A.Fake<IFilterManager>();
A.CallTo(() => fakeFilterManager.Process(A<CommandBase>.Ignored)).Returns(true);
var processor = new CommandProcessor(null, fakeFilterManager);
var command = new TestCommand(CommandState.New, executeAction: () =>
{
throw thrownException;
});
processor.PublishCommand(command, Observer.Create<ICommandResponse<Unit>>(_ => { }, ex =>
{
expectedException = ex;
wasThrown = true;
resetEvent.Set();
}));
resetEvent.Wait();
Assert.IsTrue(wasThrown);
Assert.AreEqual(expectedException, thrownException);
}