public void BadRequestWithEmptyErrorInformation() { var controller = new DummyController { Configuration = new HttpConfiguration(), Request = new HttpRequestMessage() }; var errorInformation = new Error[0]; var result = controller.BadRequest(errorInformation); result.Should().BeOfType <BadRequestWithErrorSetResult>().And.Should().NotBeNull("because a result should have been generated"); result.Content.Errors.Should().NotBeNull("because an enumeration of errors should have been returned."); result.Content.Errors.Should().HaveCount(0); }
public void BadRquestWithErrorSet() { var controller = new DummyController { Configuration = new HttpConfiguration(), Request = new HttpRequestMessage() }; var error = new Error("test-errorCode", "test-memberPath", "test-description"); var errorSet = new ErrorSet(error); var result = controller.BadRequest(errorSet); result.Should().BeOfType <BadRequestWithErrorSetResult>().And.Should().NotBeNull("because a result should have been generated"); result.Content.Errors.Should().NotBeNull("because errors should have been returned."); result.Content.Errors.Should().HaveCount(1); result.Content.Errors.First().ShouldBeEquivalentTo(error); }
public void BadRequestWithEnumerable() { var controller = new DummyController { Configuration = new HttpConfiguration(), Request = new HttpRequestMessage() }; var error1 = new Error("test-errorCode1", "test-memberPath1", "test-description1"); var error2 = new Error("test-errorCode2", "test-memberPath2", "test-description2"); var enumerableError = new [] { error1, error2 }; var result = controller.BadRequest(enumerableError); result.Should().BeOfType <BadRequestWithErrorSetResult>().And.Should().NotBeNull("because a result should have been generated"); result.Content.Errors.Should().NotBeNull("because an enumeration of errors should have been returned."); result.Content.Errors.Should().HaveCount(2); result.Content.Errors.First().ShouldBeEquivalentTo(error1); result.Content.Errors.Last().ShouldBeEquivalentTo(error2); }