public void IfNullOrNotCastableWithMessage() { // ARRANGE object somethingNotCastable = new object(); // ACT var exception = Assert.Throws <DesignByContractViolationException>( () => Fail.IfNullOrNotCastable <IQueryable>(somethingNotCastable, Violation.Of("wrong type")) ); // ASSERT Assert.That(exception.Message, Is.EqualTo("wrong type")); }
public void IfNullOrNotCastable() { // ARRANGE object somethingNotCastable = new object(); // ACT var exception = Assert.Throws <DesignByContractViolationException>( () => Fail.IfNullOrNotCastable <IQueryable>(somethingNotCastable) ); // ASSERT Assert.That(exception.Message, Is.EqualTo("Expected object of type 'System.Linq.IQueryable' but was 'System.Object'")); }
public void IfNullOrNotCastableWithNull() { // ARRANGE object somethingNotCastable = null; // ACT var exception = Assert.Throws <DesignByContractViolationException>( // ReSharper disable once ExpressionIsAlwaysNull () => Fail.IfNullOrNotCastable <IQueryable>(somethingNotCastable) ); // ASSERT Assert.That(exception.Message, Is.EqualTo("Expected object of type 'System.Linq.IQueryable' but was 'null'")); }
public void IfNullOrNotCastableSuccessWithMessage() { Fail.IfNullOrNotCastable <IList <string> >(new List <string>(), Violation.Of("wrong type")); }
public void IfNullOrNotCastableSuccess() { Fail.IfNullOrNotCastable <IList <string> >(new List <string>()); }