コード例 #1
0
        public void CheckCollectionNullOrEmpty_WithEmptyCollection_ThrowsArgumentException()
        {
            // Arrange
            var modelWithEmptyCollection = new GuardTestModel("Test", new object(), new List <object>());

            // Act & Assert
            Assert.Throws <ArgumentException>(() => Guard.CollectionNotNullOrEmpty(() => modelWithEmptyCollection.TestCollection));
        }
コード例 #2
0
        public void CheckingStringNullOrEmpty_WithNullOrEmptyString_ThrowsArgumentException(string actual)
        {
            // Arrange
            var modelWithNullString = new GuardTestModel(actual, new object(), new List <object>());

            // Act & Assert
            Assert.Throws <ArgumentException>(
                () => Guard.StringNotNullOrEmpty(() => modelWithNullString.TestString));
        }
コード例 #3
0
        public void CheckingObjectNull_WithSetObject_DoesNotThrowException()
        {
            // Arrange
            var modelWithSetobject = new GuardTestModel("Test", new object(), new List <object>());

            var act = () => Guard.ObjectNotNull(() => modelWithSetobject.TestObject);

            // Act & Assert
            act.Should().NotThrow();
        }
コード例 #4
0
        public void CheckStringNullOrEmpty_WithSetString_DoesNotThrowException()
        {
            // Arrange
            var modelWithSetString = new GuardTestModel("Test", new object(), new List <object>());

            var act = () => Guard.StringNotNullOrEmpty(() => modelWithSetString.TestString);

            // Act & Assert
            act.Should().NotThrow();
        }
コード例 #5
0
        public void CheckCollectionNullOrEmpty_WithFilledCollection_DoesNotThrowException()
        {
            // Arrange
            var modelWithFilledCollection = new GuardTestModel(
                "Test",
                new object(),
                new List <object>
            {
                new object()
            });

            var act = () => Guard.CollectionNotNullOrEmpty(() => modelWithFilledCollection.TestCollection);

            // Act & Assert
            act.Should().NotThrow();
        }