public void Constructor_Sets_Default_Message_If_None_Specified() { // Arrange/Act InvalidModelStateException ex = new InvalidModelStateException(); // Assert Assert.AreEqual(TargetResources.Error_ModelStateInvalid, ex.Message); }
public void Constructor_Sets_Message_If_Specified() { // Arrange/Act const string expected = "FooBarBaz"; InvalidModelStateException ex= new InvalidModelStateException(expected); // Assert Assert.AreEqual(expected, ex.Message); }
public void Constructor_Sets_InnerException_If_Specified() { // Arrange/Act Exception expected = new Exception(); InvalidModelStateException ex = new InvalidModelStateException(String.Empty, expected); // Assert Assert.AreSame(expected, ex.InnerException); }
public void InvalidModelStateException_Serializes_Correctly() { var modelState = new ModelStateDictionary(); modelState.AddModelError("Field", "This field is required"); var ex = new InvalidModelStateException(modelState); var expected = "[{\"Field\":\"Field\",\"Errors\":[\"This field is required\"]}]"; ex.InnerException.Message.Should().Be(expected); }