Exemple #1
0
        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"));
        }
Exemple #2
0
        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'"));
        }
Exemple #3
0
        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'"));
        }
Exemple #4
0
 public void IfNullOrNotCastableSuccessWithMessage()
 {
     Fail.IfNullOrNotCastable <IList <string> >(new List <string>(), Violation.Of("wrong type"));
 }
Exemple #5
0
 public void IfNullOrNotCastableSuccess()
 {
     Fail.IfNullOrNotCastable <IList <string> >(new List <string>());
 }