Esempio n. 1
0
        private void RespondWithError(string message, IRespondWithResultFreeSuccessOrError <ErrorOutputMessage> presenter)
        {
            var errorOutputMessage = new ErrorOutputMessage();

            errorOutputMessage.AddError(message);
            presenter.Respond(errorOutputMessage);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 4
0
        private void RespondWithMissingIdError(Guid id, IRespondWithResultFreeSuccessOrError <ErrorOutputMessage> presenter)
        {
            var errorOutputMessage = new ErrorOutputMessage();

            errorOutputMessage.AddError($"Could not locate item with id [{id}]");
            presenter.Respond(errorOutputMessage);
        }
Esempio n. 5
0
        private static void RepsondWithNullFilter(IRespondWithSuccessOrError <List <TodoTo>, ErrorOutputMessage> presenter)
        {
            var errors = new ErrorOutputMessage();

            errors.AddError("Null filter object");
            presenter.Respond(errors);
        }
Esempio n. 6
0
        public void FetchErrors_WhenConstructed_ShouldReturnList()
        {
            //---------------Set up test pack-------------------
            //---------------Execute Test ----------------------
            var result = new ErrorOutputMessage();

            //---------------Test Result -----------------------
            Assert.NotNull(result.Errors);
        }
Esempio n. 7
0
        public void HasErrors_WhenNoErrors_ShouldReturnFalse()
        {
            //---------------Set up test pack-------------------
            var errorOutputTo = new ErrorOutputMessage();
            //---------------Execute Test ----------------------
            var result = errorOutputTo.HasErrors;

            //---------------Test Result -----------------------
            Assert.False(result);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
 public void Respond(ErrorOutputMessage output)
 {
     _errors = output;
 }