コード例 #1
0
        public void SubtractMonths_WhenSubtractingMonths_ReturnNewInstance()
        {
            // Arrange

            var date = new DuodecimDate(2018, 6);

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

            // Assert
            Assert.False(Equals(date, newDate));
        }
コード例 #2
0
        public void SubtractMonths_WhenSubtractingMonths_MonthsSubtracted()
        {
            // Arrange
            const int startMonth       = 8;
            const int monthsToSubtract = 3;
            const int expectedMonth    = startMonth - monthsToSubtract;

            var date = new DuodecimDate(2018, startMonth);

            // Act
            var newDate = date.SubtractMonths(monthsToSubtract);

            // Assert
            Assert.Equal(expectedMonth, newDate.Month);
        }
コード例 #3
0
        SubtractMonths_WhenSubtractingMonthsSoTheResultYieldsAnInvalidDate_ThrowInvalidDuodecimDateException()
        {
            // Arrange
            const int startYear                 = 1;
            const int startMonth                = 6;
            const int monthsToSubtract          = startMonth + 1;
            const int expectedErrorMessageYear  = 0;
            const int expectedErrorMessageMonth = 11;

            var date = new DuodecimDate(startYear, startMonth);

            // Act
            var exception = Record.Exception(() => date.SubtractMonths(monthsToSubtract));

            // Assert
            exception.Verify <InvalidDuodecimDateException>(string.Format(ExpectedInvalidDuodecimDateExceptionMessage,
                                                                          expectedErrorMessageYear, expectedErrorMessageMonth));
        }
コード例 #4
0
        SubtractMonths_WhenMonthAndSunbtracteddMonthExceedMonthsInYear_OneYearSubtractedAndExpectedNewMonthSet()
        {
            // Arrange
            const int totalMonthsInYear = 12;
            const int startyear         = 2018;
            const int startMonth        = 1;
            const int monthsToSubtract  = 1;

            const int expectedYear  = startyear - 1;
            const int expectedMonth = totalMonthsInYear + startMonth - monthsToSubtract;

            var date = new DuodecimDate(startyear, startMonth);

            // Act
            var newDate = date.SubtractMonths(monthsToSubtract);

            // Assert
            Assert.Equal(expectedMonth, newDate.Month);
            Assert.Equal(expectedYear, newDate.Year);
        }
コード例 #5
0
        public void SubtractMonths_WhenSubtractingMoreMonthsThanExistInAYear_YearAndMonthsSubtracted()
        {
            // Arrange
            const int totalMonthsInYear = 12;
            const int startyear         = 2018;
            const int startMonth        = 10;
            const int monthsToSubtract  = 29;

            const int expectedYear  = 2016;
            const int expectedMonth = startMonth - (monthsToSubtract % totalMonthsInYear);

            var date = new DuodecimDate(startyear, startMonth);

            // Act
            var newDate = date.SubtractMonths(monthsToSubtract);

            // Assert
            Assert.Equal(expectedMonth, newDate.Month);
            Assert.Equal(expectedYear, newDate.Year);
        }