public void ThenWillEmptyCollectionIfNotActiveRules()
        {
            //Arrange
            var reservationDates = new ReservationDates
            {
                TrainingStartDate      = DateTime.Now.AddDays(30),
                ReservationStartDate   = DateTime.Now.AddDays(20),
                ReservationExpiryDate  = DateTime.Now.AddDays(40),
                ReservationCreatedDate = DateTime.Now.AddDays(18)
            };

            var course = new Course("1", "Test", "1", DateTime.Today);

            var unactiveRule = new Rule
            {
                ActiveFrom = DateTime.Now.AddDays(-2),
                ActiveTo   = DateTime.Now.AddDays(-4)
            };

            course.Rules.Add(unactiveRule);

            //Act
            var result = course.GetActiveRules(reservationDates);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsEmpty(result);
        }
        public void ThenWillNotIncludeRulesCreatedAfterReservationStartDate()
        {
            //Arrange
            var reservationDates = new ReservationDates
            {
                TrainingStartDate      = DateTime.Now.AddDays(10),
                ReservationStartDate   = DateTime.Now,
                ReservationExpiryDate  = DateTime.Now.AddDays(20),
                ReservationCreatedDate = DateTime.Now.AddDays(-5)
            };

            var course = new Course("1", "Test", "1", DateTime.Today);

            var unactiveRule = new Rule
            {
                CreatedDate = DateTime.Now,
                ActiveFrom  = DateTime.Now.AddDays(5),
                ActiveTo    = DateTime.Now.AddDays(15)
            };

            course.Rules.Add(unactiveRule);

            //Act
            var result = course.GetActiveRules(reservationDates);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsEmpty(result);
        }
        public void ThenWillReturnActiveRules(string ruleActiveFromDate, string ruleActiveToDate, int expectedRuleCount)
        {
            //Arrange
            var reservationDates = new ReservationDates
            {
                TrainingStartDate      = new DateTime(2019, 2, 1),
                ReservationStartDate   = new DateTime(2019, 1, 20),
                ReservationExpiryDate  = new DateTime(2019, 3, 1),
                ReservationCreatedDate = new DateTime(2019, 1, 18)
            };

            var course = new Course("1", "Test", "1", DateTime.Today);

            var activeRule = new Rule
            {
                ActiveFrom = DateTime.Parse(ruleActiveFromDate),
                ActiveTo   = DateTime.Parse(ruleActiveToDate)
            };

            course.Rules.Add(activeRule);

            //Act
            var result = course.GetActiveRules(reservationDates);

            //Assert

            Assert.IsNotNull(result);

            var rules = result as Rule[] ?? result.ToArray();

            Assert.AreEqual(expectedRuleCount, rules.Length);
        }