Пример #1
0
        public void GetProperDateTime_ReturnsFirstDayOfMonth_ForNotFirstDayOfMonth()
        {
            //Arrange
            MonthsProcessor processor = new MonthsProcessor();
            DateTime        baseDate  = new DateTime(2016, 8, 13, 0, 0, 0);

            //Act
            DateTime actualDateTime = processor.GetProperDateTime(baseDate, 1);

            //Assert
            DateTime expectedDateTime = new DateTime(2016, 8, 1, 0, 0, 0);

            Assert.AreEqual(expectedDateTime, actualDateTime);
        }
Пример #2
0
        public void GetNext_ReturnsProperValue_ForOtherThanFirstDay()
        {
            //Arrange
            MonthsProcessor processor = new MonthsProcessor();
            DateTime        baseDate  = new DateTime(2017, 5, 7, 16, 0, 0);

            //Act
            DateTime actualDateTime = processor.GetNext(baseDate, 1);

            //Assert
            DateTime expectedDateTime = new DateTime(2017, 6, 1, 0, 0, 0);

            Assert.AreEqual(expectedDateTime, actualDateTime);
        }
Пример #3
0
        public void AddTimeUnits_ReturnsTheSameDate_ForUnitsUnderZero()
        {
            //Arrange
            MonthsProcessor processor = new MonthsProcessor();
            DateTime        baseDate  = new DateTime(2016, 4, 1);

            //Act
            DateTime result = processor.AddTimeUnits(baseDate, 1, -5);

            //Assert
            DateTime expectedDateTime = new DateTime(2015, 11, 1);

            Assert.AreEqual(expectedDateTime, result);
        }
Пример #4
0
        public void CountTimeUnits_ReturnsZero_IfTheSameDateIsGiven()
        {
            //Arrange
            MonthsProcessor processor    = new MonthsProcessor();
            DateTime        baseDate     = new DateTime(2017, 5, 4, 0, 0, 0);
            DateTime        comparedDate = new DateTime(2017, 5, 4, 0, 0, 0);

            //Act
            int unitsBetween = processor.CountTimeUnits(baseDate, comparedDate, 1);

            //Assert
            int expected = 0;

            Assert.AreEqual(expected, unitsBetween);
        }
Пример #5
0
        public void CountTimeUnits_ReturnsProperValue_IfComparedDateIsFromPreviousYear()
        {
            //Arrange
            MonthsProcessor processor    = new MonthsProcessor();
            DateTime        baseDate     = new DateTime(2016, 4, 20);
            DateTime        comparedDate = new DateTime(2012, 6, 21);

            //Act
            int unitsBetween = processor.CountTimeUnits(baseDate, comparedDate, 1);

            //Assert
            int expected = -46;

            Assert.AreEqual(expected, unitsBetween);
        }
Пример #6
0
        public void CountTimeUnits_ReturnsProperValue_IfBaseDateIsEarlier()
        {
            //Arrange
            MonthsProcessor processor    = new MonthsProcessor();
            DateTime        baseDate     = new DateTime(2016, 4, 1);
            DateTime        comparedDate = new DateTime(2016, 4, 21);

            //Act
            int unitsBetween = processor.CountTimeUnits(baseDate, comparedDate, 1);

            //Assert
            int expected = 0;

            Assert.AreEqual(expected, unitsBetween);
        }
Пример #7
0
        public void CountTimeUnits_ReturnsZero_IfBothDatesInTheSameWeekButBaseDateIsLater()
        {
            //Arrange
            MonthsProcessor processor    = new MonthsProcessor();
            DateTime        baseDate     = new DateTime(2016, 4, 15);
            DateTime        comparedDate = new DateTime(2016, 4, 2);

            //Act
            int unitsBetween = processor.CountTimeUnits(baseDate, comparedDate, 1);

            //Assert
            int expected = 0;

            Assert.AreEqual(expected, unitsBetween);
        }
Пример #8
0
        public void CountTimeUnits_ReturnsProperValue_IfComparedDateIsNotFirstDayOfMonth()
        {
            //Arrange
            MonthsProcessor processor    = new MonthsProcessor();
            DateTime        baseDate     = new DateTime(2016, 4, 1);
            DateTime        comparedDate = new DateTime(2016, 11, 16);

            //Act
            int unitsBetween = processor.CountTimeUnits(baseDate, comparedDate, 1);

            //Assert
            int expected = 7;

            Assert.AreEqual(expected, unitsBetween);
        }