Ejemplo n.º 1
0
        public void IsTimeSlogValidForBoard_TimeIsNotSpecified_ThrowsException()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid());
            var timeSlot      = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Control);

            Assert.Throws <ArgumentNullException>(() => unitUnderTest.IsTimeSlogValidForBoard(timeSlot));
        }
Ejemplo n.º 2
0
        public SchedulingBoard ToEntity()
        {
            var retValue = new SchedulingBoard(Guid.NewGuid())
            {
                StartsAt = ShiftStartsAt
            };

            return(retValue);
        }
Ejemplo n.º 3
0
        public Task PersistNewSchedulingBoard(SchedulingBoard schedulingBoard)
        {
            if (Context.SchedulingBoards.ToList()
                .Any(m => (Math.Abs((m.StartsAt - schedulingBoard.StartsAt).TotalHours) < 8)))
            {
                throw new InvalidOperationException("Scheduling boards cannot overlap each other");
            }

            return(MakePersistent(schedulingBoard));
        }
Ejemplo n.º 4
0
        public void Usage_EmptyBoard_Success()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid())
            {
                StartsAt = DateTime.Today.Date.AddDays(1).AddHours(8)
            };

            var result = unitUnderTest.Usage;

            Assert.Equal(0, result);
        }
Ejemplo n.º 5
0
        public void GetTimeForTimeSlot_EmptyBoard_Success()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid())
            {
                StartsAt = DateTime.Today.Date.AddDays(1).AddHours(8)
            };

            var scheduledAt = unitUnderTest.GetTimeForTimeSlot(TimeSlotFactory.CreateTimeSlot(TimeSlotType.Control));

            Assert.NotNull(scheduledAt);
            Assert.Equal(unitUnderTest.StartsAt, scheduledAt);
        }
Ejemplo n.º 6
0
        public void IsTimeSlogValidForBoard_TimeSlotIsBeforeStartOfBoard_Success()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid())
            {
                StartsAt = DateTime.Now.AddHours(2)
            };
            var timeSlot = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Control);

            timeSlot.SetTime(DateTime.Now.AddHours(1));

            var result = unitUnderTest.IsTimeSlogValidForBoard(timeSlot);

            Assert.False(result);
        }
Ejemplo n.º 7
0
        public async Task GetBoardAsync_HandleResult_Success()
        {
            var id = Guid.NewGuid();
            var schedulingBoard          = new SchedulingBoard(id);
            var schedulingRepositoryMock = new Mock <ISchedulingRepository>();

            schedulingRepositoryMock.Setup(m => m.FetchBoardAsync(id)).ReturnsAsync(schedulingBoard);
            var unitUnderTest = new SchedulingBoardController(schedulingRepositoryMock.Object);

            var result = await unitUnderTest.GetBoardAsync(id);

            Assert.IsType <OkObjectResult>(result);
            Assert.Equal(id, (((ObjectResult)result).Value as SchedulingBoard)?.Id);
        }
Ejemplo n.º 8
0
        public void GetTimeForTimeSlot_FreeSpotOnBeginningOfInterval_Success()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid())
            {
                StartsAt = DateTime.Today.Date.AddDays(1).AddHours(8)
            };
            var timeSlot = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Control);

            timeSlot.SetTime(unitUnderTest.StartsAt.AddHours(2));
            unitUnderTest.AddTimeSlot(timeSlot);

            var scheduledAt = unitUnderTest.GetTimeForTimeSlot(TimeSlotFactory.CreateTimeSlot(TimeSlotType.Control));

            Assert.NotNull(scheduledAt);
            Assert.Equal(unitUnderTest.StartsAt, scheduledAt);
        }
Ejemplo n.º 9
0
        public void AddTimeSlot_TimeSlotWithoutTimeNotPossible_Success()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid())
            {
                StartsAt = DateTime.Today.Date.AddDays(1).AddHours(8)
            };

            for (int i = 0; i < 4; i++)
            {
                var timeSlot = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Intervention);
                timeSlot.SetTime(unitUnderTest.StartsAt.AddMinutes(120 * i));
                unitUnderTest.AddTimeSlot(timeSlot);
            }

            var result = unitUnderTest.AddTimeSlot(TimeSlotFactory.CreateTimeSlot(TimeSlotType.Control));

            Assert.False(result);
        }
Ejemplo n.º 10
0
        public void Usage_FullBoardButBreaksDoesNotCount_Success()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid())
            {
                StartsAt = DateTime.Today.Date.AddDays(1).AddHours(8)
            };

            for (int i = 0; i < 4; i++)
            {
                var timeSlotIntervention = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Intervention);
                timeSlotIntervention.SetTime(unitUnderTest.StartsAt.AddMinutes(120 * i));
                unitUnderTest.AddTimeSlot(timeSlotIntervention);
            }

            var result = unitUnderTest.Usage;

            Assert.Equal((decimal)0.75, result);
        }
Ejemplo n.º 11
0
        public void Usage_FullBoard_Success()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid())
            {
                StartsAt = DateTime.Today.Date.AddDays(1).AddHours(8)
            };

            for (int i = 0; i < 16; i++)
            {
                var timeSlot = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Control);
                timeSlot.SetTime(unitUnderTest.StartsAt.AddMinutes(30 * i));
                unitUnderTest.AddTimeSlot(timeSlot);
            }

            var result = unitUnderTest.Usage;

            Assert.Equal(1, result);
        }
Ejemplo n.º 12
0
        public void IsTimeSlogValidForBoard_OverlappingAtTheEnd_Success()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid())
            {
                StartsAt = DateTime.Today.Date.AddDays(1).AddHours(8)
            };

            var timeSlotExamination = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Examination);

            timeSlotExamination.SetTime(unitUnderTest.StartsAt.AddHours(1));
            unitUnderTest.AddTimeSlot(timeSlotExamination);

            var timeSlotControl = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Examination);

            timeSlotControl.SetTime(unitUnderTest.StartsAt.AddMinutes(30));
            var isValid = unitUnderTest.IsTimeSlogValidForBoard(timeSlotControl);

            Assert.False(isValid);
        }
Ejemplo n.º 13
0
        public void GetTimeForTimeSlot_BoardIsCompletelyFull_Success()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid())
            {
                StartsAt = DateTime.Today.Date.AddDays(1).AddHours(8)
            };

            for (int i = 0; i < 3; i++)
            {
                var timeSlotIntervention = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Intervention);
                timeSlotIntervention.SetTime(unitUnderTest.StartsAt.AddHours(2 * i));
                unitUnderTest.AddTimeSlot(timeSlotIntervention);
            }
            var timeSlotExamination = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Examination);

            timeSlotExamination.SetTime(unitUnderTest.StartsAt.AddHours(6));
            unitUnderTest.AddTimeSlot(timeSlotExamination);

            var scheduledAt = unitUnderTest.GetTimeForTimeSlot(TimeSlotFactory.CreateTimeSlot(TimeSlotType.Intervention));

            Assert.Null(scheduledAt);
        }
Ejemplo n.º 14
0
        public void GetTimeForTimeSlot_FreeSpotAtTheEndOfIntervalNoTimeForBreak_Success()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid())
            {
                StartsAt = DateTime.Today.Date.AddDays(1).AddHours(8)
            };

            for (int i = 0; i < 3; i++)
            {
                var timeSlotIntervention = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Intervention);
                timeSlotIntervention.SetTime(unitUnderTest.StartsAt.AddHours(2 * i));
                unitUnderTest.AddTimeSlot(timeSlotIntervention);
            }
            var timeSlotControl = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Control);

            timeSlotControl.SetTime(unitUnderTest.StartsAt.AddHours(6));
            unitUnderTest.AddTimeSlot(timeSlotControl);

            var scheduledAt = unitUnderTest.GetTimeForTimeSlot(TimeSlotFactory.CreateTimeSlot(TimeSlotType.Intervention));

            Assert.NotNull(scheduledAt);
            Assert.NotEqual(unitUnderTest.StartsAt, scheduledAt);
        }
Ejemplo n.º 15
0
        public void IsTimeSlogValidForBoard_ArgumentIsNotSpecified_ThrowsException()
        {
            var unitUnderTest = new SchedulingBoard(Guid.NewGuid());

            Assert.Throws <ArgumentNullException>(() => unitUnderTest.IsTimeSlogValidForBoard(null));
        }