public void WhenDTOIsInValidThenThrow() { //Xunit.Assert.Throws<MissingMemberException>(() => //{ // var x = new SomeClassWithoutValidate(); // x.If().IsInvalid.ThenThrow(); //}); var res = Xunit.Assert.Throws <ArgumentNullException>(() => { var x = new SomeClassWithValidate(); x.If("s").IsInvalid.ThenThrow(); }); Assert.True(res.Message.StartsWith("Name1 must be shorter than 7 characters and Number1 must not be equal to 0 and Name2 must be shorter than 6 characters and Number2 must not be equal to 0")); }
public void WhenDTOIsInValidThenThrow() { //Xunit.Assert.Throws<MissingMemberException>(() => //{ // var x = new SomeClassWithoutValidate(); // x.If().IsInvalid.ThenThrow(); //}); var res = Xunit.Assert.Throws<ArgumentNullException>(() => { var x = new SomeClassWithValidate(); x.If("s").IsInvalid.ThenThrow(); }); Assert.True(res.Message.StartsWith("Name1 must be shorter than 7 characters and Number1 must not be equal to 0 and Name2 must be shorter than 6 characters and Number2 must not be equal to 0")); }