private void RespondWithError(string message, IRespondWithResultFreeSuccessOrError <ErrorOutputMessage> presenter) { var errorOutputMessage = new ErrorOutputMessage(); errorOutputMessage.AddError(message); presenter.Respond(errorOutputMessage); }
private void RespondWithInvalidItemDescription(IRespondWithSuccessOrError <CreateTodoOutput, ErrorOutputMessage> presenter) { var errors = new ErrorOutputMessage(); errors.AddError("ItemDescription cannot be empty or null"); presenter.Respond(errors); }
public void RespondWithErrorMessage(string message, IRespondWithSuccessOrError <CreateCommentOutput, ErrorOutputMessage> presenter) { var errorOutputMessage = new ErrorOutputMessage(); errorOutputMessage.AddError(message); presenter.Respond(errorOutputMessage); }
private void RespondWithMissingIdError(Guid id, IRespondWithResultFreeSuccessOrError <ErrorOutputMessage> presenter) { var errorOutputMessage = new ErrorOutputMessage(); errorOutputMessage.AddError($"Could not locate item with id [{id}]"); presenter.Respond(errorOutputMessage); }
private static void RepsondWithNullFilter(IRespondWithSuccessOrError <List <TodoTo>, ErrorOutputMessage> presenter) { var errors = new ErrorOutputMessage(); errors.AddError("Null filter object"); presenter.Respond(errors); }
public void FetchErrors_WhenConstructed_ShouldReturnList() { //---------------Set up test pack------------------- //---------------Execute Test ---------------------- var result = new ErrorOutputMessage(); //---------------Test Result ----------------------- Assert.NotNull(result.Errors); }
public void HasErrors_WhenNoErrors_ShouldReturnFalse() { //---------------Set up test pack------------------- var errorOutputTo = new ErrorOutputMessage(); //---------------Execute Test ---------------------- var result = errorOutputTo.HasErrors; //---------------Test Result ----------------------- Assert.False(result); }
public void HasErrors_WhenErrors_ShouldReturnTrue() { //---------------Set up test pack------------------- var errorOutputTo = new ErrorOutputMessage(); errorOutputTo.AddError("test error"); //---------------Execute Test ---------------------- var result = errorOutputTo.HasErrors; //---------------Test Result ----------------------- Assert.True(result); }
public void ErrorContent_WhenErrors_ShouldReturnErrorTo() { //---------------Set up test pack------------------- var errors = new ErrorOutputMessage(); var presenter = new PropertyPresenter <object, ErrorOutputMessage>(); presenter.Respond(errors); //---------------Execute Test ---------------------- var result = presenter.ErrorContent; //---------------Test Result ----------------------- Assert.AreEqual(errors, result); }
public void IsErrorResponse_WhenErrorObjectNotNull_ShouldReturnTrue() { //---------------Set up test pack------------------- var errorObject = new ErrorOutputMessage(); errorObject.AddError("stuff went wrong"); var presenter = new PropertyPresenter <string, ErrorOutputMessage>(); //---------------Execute Test ---------------------- presenter.Respond(errorObject); //---------------Test Result ----------------------- Assert.IsTrue(presenter.IsErrorResponse()); }
public void Respond_WhenErrorObject_ShouldSetErrorProperty() { //---------------Set up test pack------------------- var errorObject = new ErrorOutputMessage(); errorObject.AddError("stuff went wrong"); var presenter = new PropertyPresenter <string, ErrorOutputMessage>(); //---------------Execute Test ---------------------- presenter.Respond(errorObject); //---------------Test Result ----------------------- Assert.AreEqual(errorObject, presenter.ErrorContent); }
public void Render_GivenErrorResponse_ShouldReturnUnprocessableEntityResultWithContent() { //---------------Set up test pack------------------- var content = new ErrorOutputMessage(); var presenter = CreatePresenter(); presenter.Respond(content); //---------------Execute Test ---------------------- var result = presenter.Render() as UnprocessasbleEntityResult <ErrorOutputMessage>; //---------------Test Result ----------------------- Assert.IsNotNull(result); Assert.AreEqual(content, result.Content); }
public void Render_WhenErrorsPresent_ShouldRenderErrors() { //---------------Arrange------------------ var errors = new ErrorOutputMessage { Errors = { "error 1", "error 2", "error 3" } }; var fakeoutput = new StringBuilder(); Console.SetOut(new StringWriter(fakeoutput)); var sut = new ConsolePresenter(); //---------------Act---------------------- sut.Respond(errors); sut.Render(); //---------------Assert------------------- var expected = $"The following errors occured:{Environment.NewLine}" + $"error 1{Environment.NewLine}" + $"error 2{Environment.NewLine}" + $"error 3{Environment.NewLine}"; fakeoutput.ToString().Should().Be(expected); }
public void Respond(ErrorOutputMessage output) { _errors = output; }