public void IfCollectionEmptyWithMessage([CanBeNull] IEnumerable collection)
        {
            var exception = Assert.Throws <DesignByContractViolationException>(
                () => Fail.IfCollectionEmpty(collection, Violation.Of("collection cannot be null or empty"))
                );

            // ASSERT
            Assert.That(exception.Message, Is.EqualTo("collection cannot be null or empty"));
        }
Ejemplo n.º 2
0
        public void IfCollectionEmpty()
        {
            IEnumerable <object> pusta     = Enumerable.Empty <object>();
            IEnumerable <object> nullowata = null;
            IEnumerable <string> pełna     = Enumerable.Repeat("element", 2);

            Assert.Throws <DesignByContractViolationException>(
                () => Fail.IfCollectionEmpty(pusta, "collection")
                );

            Assert.Throws <DesignByContractViolationException>(
                // ReSharper disable once ExpressionIsAlwaysNull
                () => Fail.IfCollectionEmpty(nullowata, "collection")
                );

            Fail.IfCollectionEmpty(pełna, "collection");
        }
 public void IfCollectionEmptySuccessWithMessage([NotNull] IEnumerable collection)
 {
     Fail.IfCollectionEmpty(collection, Violation.Of("collection cannot be null or empty"));
 }
 public void IfCollectionEmptySuccessWithName([NotNull] IEnumerable collection)
 {
     Fail.IfCollectionEmpty(collection, "collection");
 }
 public void IfCollectionEmptyWithName([CanBeNull] IEnumerable collection)
 {
     Assert.Throws <DesignByContractViolationException>(
         () => Fail.IfCollectionEmpty(collection, nameof(collection))
         );
 }