Example #1
0
        public void NotEmpty_PropertyIsEmpty_Fails()
        {
            // Arrange
            var testClass = new VerificationTestClass
            {
                StringProperty = string.Empty
            };

            StringVerifier <VerificationTestClass> sut = CreateStringVerifier(testClass);

            // Act & Assert
            Assert.Throws <Exception>(() => sut.NotEmpty());
        }
Example #2
0
        public void Regex_PropertyDoesntMatchPattern_Fails()
        {
            // Arrange
            var testClass = new VerificationTestClass
            {
                StringProperty = "blabla"
            };

            StringVerifier <VerificationTestClass> sut = CreateStringVerifier(testClass);

            // Act & Assert
            Assert.Throws <Exception>(() => sut.Regex(@"\d+"));
        }
Example #3
0
        public void Max_PropertyHigherThanMax_Fails()
        {
            // Arrange
            var testClass = new VerificationTestClass
            {
                IntProperty = 5
            };

            IntVerifier <VerificationTestClass> sut = CreateIntVerifier(testClass);

            // Act & Assert
            Assert.Throws <Exception>(() => sut.Max(1));
        }
Example #4
0
        public void Min_PropertyLowerThanMin_Fails()
        {
            // Arrange
            var testClass = new VerificationTestClass
            {
                IntProperty = -1
            };

            IntVerifier <VerificationTestClass> sut = CreateIntVerifier(testClass);

            // Act & Assert
            Assert.Throws <Exception>(() => sut.Min(0));
        }
Example #5
0
        public void Regex_PropertyMatchesPattern_Passes()
        {
            // Arrange
            var testClass = new VerificationTestClass
            {
                StringProperty = "123"
            };

            StringVerifier <VerificationTestClass> sut = CreateStringVerifier(testClass);

            // Act
            Exception exception = Record.Exception(() => sut.Regex(@"\d+"));

            // Assert
            Assert.Null(exception);
        }
Example #6
0
        public void NotEmpty_PropertyIsNull_Passes()
        {
            // Arrange
            var testClass = new VerificationTestClass
            {
                StringProperty = null
            };

            StringVerifier <VerificationTestClass> sut = CreateStringVerifier(testClass);

            // Act
            Exception exception = Record.Exception(() => sut.NotEmpty());

            // Assert
            Assert.Null(exception);
        }
Example #7
0
        public void Max_PropertyLowerThanMax_Passes()
        {
            // Arrange
            var testClass = new VerificationTestClass
            {
                IntProperty = 5
            };

            IntVerifier <VerificationTestClass> sut = CreateIntVerifier(testClass);

            // Act
            Exception exception = Record.Exception(() => sut.Max(10));

            // Assert
            Assert.Null(exception);
        }
Example #8
0
 private static StringVerifier <VerificationTestClass> CreateStringVerifier(VerificationTestClass instance)
 {
     return(new StringVerifier <VerificationTestClass>(instance, x => x.StringProperty));
 }
Example #9
0
 private static IntVerifier <VerificationTestClass> CreateIntVerifier(VerificationTestClass instance)
 {
     return(new IntVerifier <VerificationTestClass>(instance, x => x.IntProperty));
 }