コード例 #1
0
        public void PersonSecurityNumberLengthToShort()
        {
            // Arrange
            var person = new Person()
            {
                Name = "Erik",
                SecurityNumber = 19801022326
            };

            // Act
            var actual = person.SecurityNumber.ToString().Length;
            var expected = 12;

            Assert.That(actual, Is.Not.EqualTo(expected));
        }
コード例 #2
0
        private long GetDaysOfMonth(Person person)
        {
            var numberOfDayes = 0L;
            var month = long.Parse(person.SecurityNumber.ToString().Substring(4, 2));
            switch (month)
            {
                case 1:
                    numberOfDayes = 31;
                    break;
                case 2:
                    numberOfDayes = CheckLeapYear(long.Parse(person.SecurityNumber.ToString().Substring(0,4)));
                    break;
                case 3:
                    numberOfDayes = 31;
                    break;
                case 4:
                    numberOfDayes = 30;
                    break;
                case 5:
                    numberOfDayes = 31;
                    break;
                case 6:
                    numberOfDayes = 30;
                    break;
                case 7:
                    numberOfDayes = 31;
                    break;
                case 8:
                    numberOfDayes = 31;
                    break;
                case 9:
                    numberOfDayes = 30;
                    break;
                case 10:
                    numberOfDayes = 31;
                    break;
                case 11:
                    numberOfDayes = 30;
                    break;
                case 12:
                    numberOfDayes = 31;
                    break;
            }

            return numberOfDayes;
        }
コード例 #3
0
        public void PersonSecurityNumberLeapDayIsNot()
        {
            // Arrange
            var person = new Person()
            {
                Name = "Erik",
                SecurityNumber = 198102293216
            };

            // Act

            var actual = long.Parse(person.SecurityNumber.ToString().Substring(6, 2));
            var expected = GetDaysOfMonth(person);

            // Assert
            Assert.That(actual, Is.Not.InRange(1F, (float)expected));
        }
コード例 #4
0
        public void PersonSecurityNumberMonthOutOfRange()
        {
            // Arrange
            var person = new Person()
            {
                Name = "Erik",
                SecurityNumber = 198013223216
            };

            // Act

            var actual = long.Parse(person.SecurityNumber.ToString().Substring(4, 2));

            // Assert
            Assert.That(actual, Is.Not.InRange(01, 12));
        }
コード例 #5
0
        public void PersonSecurityNumberYearOutOfRange()
        {
            // Arrange
            var person = new Person()
            {
                Name = "Erik",
                SecurityNumber = 188010223216
            };

            // Act

            var actual = long.Parse(person.SecurityNumber.ToString().Substring(0, 4));

            // Assert
            Assert.That(actual, Is.Not.InRange(1900, DateTime.Now.Year));
        }
コード例 #6
0
        public void PersonSecurityNumberInFuture()
        {
            // Arrange
            var person = new Person()
            {
                Name = "Erik",
                SecurityNumber = long.Parse($"{DateTime.Now.AddDays(1).ToString("yyyyMMdd")}3216")
            };

            // Act

            var actual = person.SecurityNumber.ToString().Substring(0, 8);

            // Assert
            Assert.That(actual, Is.Not.AtMost(DateTime.Now.ToString("yyyyMMdd")));
        }
コード例 #7
0
        public void PersonSecurityNumberNotInFuture()
        {
            // Arrange
            var person = new Person()
            {
                Name = "Erik",
                SecurityNumber = 198010223216
            };

            // Act
            var actual = person.SecurityNumber.ToString().Substring(0, 8);

            // Assert
            Assert.That(actual, Is.AtMost(DateTime.Now.ToString("yyyyMMdd")));
        }