Skip to content

Commit

Permalink
add a test to show the error message thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
ElizabethOkerio committed Jun 9, 2020
1 parent 428bd14 commit 58876e8
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1652,5 +1652,27 @@ private static IEdmModel ContainmentComplexModel()
}

#endregion
[Fact]
public void NullValidationErrorMessageForCollectionsofComplexTypes()
{
string expectedErrorMessage = "A null value was found for the property named 'Addresses', which has the expected type 'Collection(DefaultNs.Address)[Nullable=False]'. The expected type 'Collection(DefaultNs.Address)[Nullable=False]' does not allow null values.";
string actualErrorMessage = "";
const string payload =
"{" +
"\"@odata.context\":\"http://host/$metadata#People/$entity\"," +
"\"UserName\":\"abc\"," +
"\"Addresses\":null" +
"}";

try
{
ReadPayload(payload, Model, EntitySet, EntityType).OfType<ODataResource>().ToList();
}
catch (Exception e)
{
actualErrorMessage = e.Message;
}
Assert.Equal(expectedErrorMessage, actualErrorMessage);
}
}
}

0 comments on commit 58876e8

Please sign in to comment.