Ejemplo n.º 1
0
        public void ThenShouldCalculateAvailabilityForEachTimeSlotReturned()
        {
            // arrange
            var  startDate   = new DateTime(2019, 7, 14);
            var  endDate     = new DateTime(2019, 7, 15);
            byte startHour   = 8;
            byte endHour     = 17;
            var  mySchedules = new List <Schedule>
            {
                new Schedule
                {
                    ScheduleItems = new ScheduleItem[]
                    {
                        new ScheduleItem
                        {
                            Name          = "Available all day",
                            StartDateTime = startDate.Date.AddHours(7),
                            EndDateTime   = startDate.AddHours(22),
                            Status        = ScheduleStatus.Available
                        }
                    }
                }
            };

            // act
            var results = new SCHEDULING.ScheduleManager().CalculateAvailability(mySchedules, startDate, endDate, startHour, endHour, AvailabilityTimeUnit.Hour);

            // assert
            Assert.Equal(1, results.First().Count);
        }
        public void ShouldExpandWithinDatesSpecified()
        {
            // arrange

            // act
            var sut     = new Fritz.ResourceManagement.Scheduling.ScheduleManager();
            var results = sut.ExpandSchedule(_MyMultipleItemSchedule, new DateTime(2019, 1, 1), new DateTime(2019, 5, 18));

            // assert
            Assert.Single(results);
        }
        public void ShouldCreateTheScheduleItemsSpecified()
        {
            // arrange

            // act
            var sut     = new Fritz.ResourceManagement.Scheduling.ScheduleManager();
            var results = sut.ExpandSchedule(_MySimpleSchedule, new DateTime(2019, 1, 1), new DateTime(2019, 12, 31));

            // assert
            Assert.NotEmpty(results);
            Assert.Equal(15, results.First().StartDateTime.Hour);
        }
        public void ShouldCreateMultipleScheduleItemsSpecified()
        {
            // arrange

            // act
            var sut     = new Fritz.ResourceManagement.Scheduling.ScheduleManager();
            var results = sut.ExpandSchedule(_MyMultipleItemSchedule, new DateTime(2019, 1, 1), new DateTime(2019, 12, 31));

            // assert
            results.Should().NotBeEmpty();
            results.Should().HaveCount(2);
            results.First().StartDateTime.Hour.Should().Be(15);
            results.Skip(1).First().StartDateTime.Hour.Should().Be(17);
        }
Ejemplo n.º 5
0
        public void ThenShouldReportAtTheGrainRequested(AvailabilityTimeUnit timeUnit)
        {
            // arrange
            var  mySchedules = new List <Schedule>();
            var  startDate   = new DateTime(2019, 7, 14);
            var  endDate     = new DateTime(2019, 7, 20);
            byte startHour   = 8;
            byte endHour     = 17;

            // act
            var results = new SCHEDULING.ScheduleManager().CalculateAvailability(mySchedules, startDate, endDate, startHour, endHour, timeUnit);

            // assert
            var expectedResults = new Dictionary <AvailabilityTimeUnit, int> {
                { AvailabilityTimeUnit.HalfHour, 126 },
                { AvailabilityTimeUnit.Hour, 63 },
                { AvailabilityTimeUnit.Day, 7 }
            };

            Assert.Equal(expectedResults[timeUnit], results.Count());
        }