public void When_deserializer_throws_then_should_throw_HttpProblemDetailsException() { var sut = new CommandHandlingSettings(A.Fake <ICommandHandlerResolver>(), A.Fake <ResolveCommandType>()); Action act = () => { using (var reader = new StringReader("xyx")) { sut.DeserializeCommand(reader, typeof(CommandHandlingSettingsTests)); } }; act.ShouldThrowExactly <HttpProblemDetailsException <HttpProblemDetails> >() .And.ProblemDetails.Status.Should().Be(400); }
public void When_custom_deserializer_throws_then_should_throw_HttpProblemDetailsException() { var sut = new CommandHandlingSettings(A.Fake <ICommandHandlerResolver>(), A.Fake <ResolveCommandType>()) { DeserializeCommand = (_, __) => { throw new Exception(); } }; Action act = () => { using (var reader = new StringReader("xyx")) { sut.DeserializeCommand(reader, typeof(CommandHandlingSettingsTests)); } }; act.ShouldThrow <HttpProblemDetailsException <HttpProblemDetails> >(); }
public void When_custom_deserializer_throws_HttpProblemDetailsException_then_it_should_propagate() { var expected = new HttpProblemDetailsException <HttpProblemDetails>(new HttpProblemDetails()); var sut = new CommandHandlingSettings(A.Fake <ICommandHandlerResolver>(), A.Fake <ResolveCommandType>()) { DeserializeCommand = (_, __) => { throw expected; } }; Exception thrown = null; try { using (var reader = new StringReader("xyx")) { sut.DeserializeCommand(reader, typeof(CommandHandlingSettingsTests)); } } catch (Exception ex) { thrown = ex; } thrown.ShouldBe(expected); }