Пример #1
0
        public void Validate_WithInvalidDateOfBirth_ExpectInvalidOperationException(
            int year,
            int month,
            int dayOfMonth,
            int todayYear,
            int todayMonth,
            int todayDayOfMonth)
        {
            // Arrange
            var classUnderTest =
                new Student(null, null)
                {
                    Today = new DateTime(todayYear, todayMonth, todayDayOfMonth),
                    DateOfBirth = new DateTime(year, month, dayOfMonth),
                };

            // Act
            TestDelegate act = () => classUnderTest.Validate();

            // Assert
            Assert.Throws<InvalidOperationException>(act,
                "Exception was not thrown for DOB {0} applying on {1}",
                classUnderTest.DateOfBirth.ToShortDateString(),
                classUnderTest.Today.ToShortDateString());
        }
Пример #2
0
        public void given_today_is_2015_05_17_given_student_dob_19930517_when_validated_expect_no_exception()
        {
            // Arrange
            var classUnderTest =
                new Student(null, null)
                {
                    Today = new DateTime(2015, 5, 17),
                    DateOfBirth = new DateTime(1993, 5, 17),
                };

            // Act
            classUnderTest.Validate();

            // Assert
            Assert.Pass("No exception thrown.");
        }
Пример #3
0
        public void Validate_WithValidDateOfBirth_ExpectNoException(
            int year,
            int month,
            int dayOfMonth,
            int todayYear,
            int todayMonth,
            int todayDayOfMonth)
        {
            // Arrange
            var classUnderTest =
                new Student(null, null)
                {
                    Today = new DateTime(todayYear, todayMonth, todayDayOfMonth),
                    DateOfBirth = new DateTime(year, month, dayOfMonth),
                };

            // Act
            classUnderTest.Validate();

            // Assert
            Assert.Pass("No exception thrown.");
        }
Пример #4
0
        public void given_today_is_2015_05_17_given_student_dob_20150518WhenValidatedExpectInvalidOperationException()
        {
            // Arrange
            var classUnderTest =
                new Student(null, null)
                {
                    Today = new DateTime(2015, 5, 17),
                    DateOfBirth = new DateTime(2015, 5, 18),
                };

            // Act
            TestDelegate act = () => classUnderTest.Validate();

            // Assert
            Assert.Throws<InvalidOperationException>(act,
                "Exception was not thrown for DOB {0} applying on {1}",
                classUnderTest.DateOfBirth.ToShortDateString(),
                classUnderTest.Today.ToShortDateString());
        }