public void ScaScheduleContext_WhenQueriedForEmployees_40RecordsAreReturned()
        {
            // arrange
            using (var context = new ScaScheduleContext())
            {
                // act
                var factilities = context.Employees.ToList();

                // assert
                Assert.AreEqual(factilities.Count, 40);
            }
        }
Exemplo n.º 2
0
        public void GetLocations_WhenCalled_Returns4Records()
        {
            using (var context = new ScaScheduleContext())
            {
                // arrange
                var queryHandler = new GetLocationsQueryHandler(context);

                // act
                var actual = queryHandler.Handle(new GetLocationsQuery());

                // assert
                Assert.AreEqual(actual.Count(), 4);
            }
        }
Exemplo n.º 3
0
        public void GetLocationQueryHandler_WhenCalled_ReturnsFacilityIdPaddedWithLeadingZeroes()
        {
            // arrange
            using (var context = new ScaScheduleContext())
            {
                var handler = new GetLocationsQueryHandler(context);

                // act
                var actual = handler.Handle(new GetLocationsQuery());

                // assert
                Assert.AreEqual(actual.ToList()[0].FacilityId.Length, 6);
                Assert.IsTrue(actual.ToList()[0].FacilityId.Contains("00000"));
            }
        }
        public void ScaScheduleContext_WhenQueriedForEmployeesInAFacility_Returns10Records()
        {
            // arrange
            using (var context = new ScaScheduleContext())
            {
                // act
                var employees =
                    from f in context.Facilities
                    join e in context.Employees on f.FacilityId equals e.FacilityId
                    where f.FacilityId == 1
                    select new { Facility = f.Name, Employee = e.Name };

                // assert
                Assert.AreEqual(employees.ToList().Count, 10);
            }
        }
Exemplo n.º 5
0
        public void GetSchedulesByFacilityAndStartDateQueryHandler_WhenQueriedForAWeeklyScheduleWithAnInvalidDate_ReturnsNoRecords()
        {
            using (var context = new ScaScheduleContext())
            {
                // arrange
                var queryHandler = new GetSchedulesByFacilityAndStartDateQueryHandler(context);

                // act
                var actual = queryHandler.Handle(new GetSchedulesByFacilityAndStartDateQuery {
                    FacilityId = 1, StartDate = new System.DateTime(2017, 1, 1)
                });

                // assert
                Assert.IsFalse(actual.Any());
            }
        }
Exemplo n.º 6
0
        public void GetWeeklySchedulesByFacilityIdAndStartDater_WhenCalledWithAValidDate_Returns10Records()
        {
            using (var context = new ScaScheduleContext())
            {
                // arrange
                var queryHandler = new GetSchedulesByFacilityAndStartDateQueryHandler(context);

                // act
                var actual = queryHandler.Handle(new GetSchedulesByFacilityAndStartDateQuery {
                    FacilityId = 1, StartDate = new System.DateTime(2018, 1, 1)
                });

                // assert
                Assert.AreEqual(actual.Count(), 10);
            }
        }
        public void ScaScheduleContext_WhenQueriedForAWeeklyScheduleWithAnInvalidDate_ReturnsNoRecords()
        {
            // arrange
            using (var context = new ScaScheduleContext())
            {
                // act
                var weeklySchedule =
                    from e in context.Employees
                    where e.FacilityId == 2
                    from s in e.SchedulesEmployees
                    where s.StartDate == new DateTime(2017, 1, 1)
                    select new { TeammateName = e.Name, EmployeeType = e.Type, Monday = s.Monday, Tuesday = s.Tuesday, Wednesday = s.Wednesday, Thursday = s.Thursday, Friday = s.Friday, Saturday = s.Saturday, Sunday = s.Sunday };

                // assert
                Assert.IsFalse(weeklySchedule.Any());
            }
        }
        public void GetSchedulesByFacilityAndStartDateQueryHandler_WhenCalledWithAValidDate_Returns10Records()
        {
            // arrange
            using (var context = new ScaScheduleContext())
            {
                var handler = new GetSchedulesByFacilityAndStartDateQueryHandler(context);

                var query = new GetSchedulesByFacilityAndStartDateQuery
                {
                    FacilityId = 1,
                    StartDate  = new DateTime(2018, 1, 1)
                };

                // act
                var actual = handler.Handle(query);

                // assert
                Assert.AreEqual(actual.ToList().Count, 10);
            }
        }
 public GetLocationsQueryHandler(ScaScheduleContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(ScaScheduleContext));
 }
Exemplo n.º 10
0
 public GetSchedulesByFacilityAndStartDateQueryHandler(ScaScheduleContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(ScaScheduleContext));
 }