コード例 #1
0
        public void SubtractYears_WhenSubtractingYears_ReturnNewInstance()
        {
            // Arrange
            var date = new DuodecimDate(2018, 6);

            // Act
            var newDate = date.SubtractYears(1);

            // Assert
            Assert.False(Equals(date, newDate));
        }
コード例 #2
0
        public void SubtractYears_WhenSubtractingNegativeYears_ThrowArgumentOutOfRangeException()
        {
            // Arrange
            const int yearsToSubtract = -1;

            var date = new DuodecimDate(2018, 6);

            // Act
            var exception = Record.Exception(() => date.SubtractYears(yearsToSubtract));

            // Assert
            exception.Verify <ArgumentOutOfRangeException>(string.Format(ExpectedYearOrMonthIsNegativeExceptionMessage,
                                                                         "years"));
        }
コード例 #3
0
        public void SubtractYears_WhenSubtractingYears_YearsSubtracted()
        {
            // Arrange
            const int startYear       = 2018;
            const int yearsToSubtract = 13;
            const int expectedYear    = startYear - yearsToSubtract;

            var date = new DuodecimDate(startYear, 6);

            // Act
            var newDate = date.SubtractYears(yearsToSubtract);

            // Assert
            Assert.Equal(expectedYear, newDate.Year);
        }
コード例 #4
0
        public void SubtractYears_WhenSubtractingYearsSoTheResultYieldsAnInvalidYear_ThrowInvalidDuodecimDateException()
        {
            // Arrange
            const int startYear                = 2018;
            const int yearsToSubtract          = startYear;
            const int expectedErrorMessageYear = startYear - yearsToSubtract;
            const int month = 6;

            var date = new DuodecimDate(startYear, 6);

            // Act
            var exception = Record.Exception(() => date.SubtractYears(yearsToSubtract));

            // Assert
            exception.Verify <InvalidDuodecimDateException>(string.Format(ExpectedInvalidDuodecimDateExceptionMessage,
                                                                          expectedErrorMessageYear, month));
        }