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. 3
0
        public void Render_GivenErrorResponse_ShouldReturnUnprocessableEntityResultWithContent()
        {
            //---------------Set up test pack-------------------
            var content = new ErrorOutputMessage();

            content.AddError("Error message");

            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);
        }