Beispiel #1
0
        public async Task GetShiftApplicationByIdShouldNotReturnShiftApplicationIfNoSuchExists()
        {
            const string id     = "Test";
            const string fakeId = "Fake";

            // Arrange
            var shiftApplication = new ShiftApplication
            {
                Id         = id,
                ShiftId    = ShiftId,
                EmployeeId = EmployeeId,
                CreatedOn  = DateTime.UtcNow,
                Status     = ShiftApplicationStatus.Pending,
            };

            this.FakeDb.Add(shiftApplication);

            this.shiftApplicationService = new ShiftApplicationService(this.GetMockedRepositoryReturningAllAsNoTracking());

            // Act
            var model = await this.shiftApplicationService.GetShiftApplicationById <ShiftApplicationTestViewModel>(fakeId);

            // Assert
            Assert.Null(model);
        }
Beispiel #2
0
        public void ApproveShiftApplicationShouldThrowIfGivenApplicationDoesNotExist()
        {
            const string id = "Test";

            // Arrange
            this.shiftApplicationService = new ShiftApplicationService(this.GetMockedRepositoryAll());

            // Act
            // Assert
            Assert.ThrowsAsync <ArgumentException>(() => this.shiftApplicationService.ApproveShiftApplicationAsync(id));
        }
Beispiel #3
0
 public ShiftApplicationController(
     IShiftApplicationService shiftApplicationService,
     IShiftService shiftService,
     IEmployeeGroupService employeeGroupService,
     IGroupService groupService,
     UserManager <PlanShiftUser> userManager)
 {
     this.shiftApplicationService = shiftApplicationService;
     this.shiftService            = shiftService;
     this.employeeGroupService    = employeeGroupService;
     this.groupService            = groupService;
     this.userManager             = userManager;
 }
Beispiel #4
0
        public async Task CreateShiftApplicationAsyncCreateEntityIfGivenCorrectItems()
        {
            // Arrange
            this.shiftApplicationService = new ShiftApplicationService(this.GetMockedRepositoryWithCreateOperations());

            // Act
            var shiftApplicationId = await this.shiftApplicationService.CreateShiftApplicationAsync(ShiftId, EmployeeId);

            // Assert
            Assert.NotNull(this.shiftApplicationService);
            Assert.Single(this.FakeDb);
            Assert.Contains(this.FakeDb, application => application.EmployeeId == EmployeeId && application.ShiftId == ShiftId);
        }
Beispiel #5
0
 public BusinessController(
     IBusinessService businessService,
     IBusinessTypeService businessTypeService,
     IShiftApplicationService shiftApplicationService,
     IShiftChangeService shiftChangeService,
     IEmployeeGroupService employeeGroupService)
 {
     this.businessService         = businessService;
     this.businessTypeService     = businessTypeService;
     this.shiftApplicationService = shiftApplicationService;
     this.shiftChangeService      = shiftChangeService;
     this.employeeGroupService    = employeeGroupService;
 }
Beispiel #6
0
        public async Task GetCountOfPendingApplicationsByBusinessIdAsyncShouldNotReturnProperCountIfPendingApplicationDoesNotExist()
        {
            const int    expectedCount  = 0;
            const string businessId     = "Test";
            const string fakeBusinessId = "Fake";

            // Model
            var shift = new Shift()
            {
                Group = new Group()
                {
                    BusinessId = businessId
                },
            };

            var shiftApplication = new ShiftApplication
            {
                ShiftId    = ShiftId,
                EmployeeId = EmployeeId,
                CreatedOn  = DateTime.UtcNow,
                Status     = ShiftApplicationStatus.Pending,
                Shift      = shift,
            };

            var shiftApplication2 = new ShiftApplication
            {
                ShiftId    = ShiftId,
                EmployeeId = EmployeeId,
                CreatedOn  = DateTime.UtcNow,
                Status     = ShiftApplicationStatus.Pending,
                Shift      = shift,
            };

            this.FakeDb.Add(shiftApplication);
            this.FakeDb.Add(shiftApplication2);

            this.shiftApplicationService = new ShiftApplicationService(this.GetMockedRepositoryReturningAllAsNoTracking());

            // Act
            var count = await this.shiftApplicationService.GetCountOfPendingApplicationsByBusinessIdAsync(fakeBusinessId);

            // Assert
            Assert.Equal(expectedCount, count);
        }
Beispiel #7
0
        public async Task HasEmployeeActiveApplicationForShiftAsyncShouldReturnTrueIfThereIsNoSuchActiveShiftApplication()
        {
            // Arrange
            var shiftApplication = new ShiftApplication
            {
                ShiftId    = ShiftId,
                EmployeeId = EmployeeId,
                CreatedOn  = DateTime.UtcNow,
                Status     = ShiftApplicationStatus.Unknown,
            };

            this.FakeDb.Add(shiftApplication);

            this.shiftApplicationService = new ShiftApplicationService(this.GetMockedRepositoryReturningAllAsNoTracking());

            // Act
            var hasEmployeeApplied = await this.shiftApplicationService.HasEmployeeActiveApplicationForShiftAsync(ShiftId, EmployeeId);

            // Assert
            Assert.False(hasEmployeeApplied);
        }
Beispiel #8
0
        public void DeclineAllShiftApplicationsPerShiftAsyncShouldThrowIfNoShiftsApplicationsForShiftFound()
        {
            const string fakeShiftId = "Fake";

            // Arrange
            var shiftApplication = new ShiftApplication
            {
                ShiftId    = fakeShiftId,
                EmployeeId = EmployeeId,
                CreatedOn  = DateTime.UtcNow,
                Status     = ShiftApplicationStatus.Pending,
            };

            this.FakeDb.Add(shiftApplication);

            this.shiftApplicationService = new ShiftApplicationService(this.GetMockedRepositoryAll());

            // Act
            // Assert
            Assert.ThrowsAsync <ArgumentException>(() => this.shiftApplicationService.DeclineAllShiftApplicationsPerShiftAsync(ShiftId));
        }
Beispiel #9
0
        public async Task DeclineAllShiftApplicationsPerShiftAsyncShouldChangeAllShiftApplicationShiftStatusToDeclined()
        {
            const string id = "Test";

            // Arrange
            var shiftApplication = new ShiftApplication
            {
                Id         = id,
                ShiftId    = ShiftId,
                EmployeeId = EmployeeId,
                CreatedOn  = DateTime.UtcNow,
                Status     = ShiftApplicationStatus.Pending,
            };

            this.FakeDb.Add(shiftApplication);

            this.shiftApplicationService = new ShiftApplicationService(this.GetMockedRepositoryAll());

            // Act
            await this.shiftApplicationService.DeclineAllShiftApplicationsPerShiftAsync(ShiftId);

            // Assert
            Assert.True(shiftApplication.Status == ShiftApplicationStatus.Declined);
        }
Beispiel #10
0
        public async Task ApproveShiftApplicationShouldChangeTheStatusOfTheApplicationIfEverythingIsCorrect()
        {
            const string id = "Test";

            // Arrange
            var shiftApplication = new ShiftApplication
            {
                Id         = id,
                ShiftId    = ShiftId,
                EmployeeId = EmployeeId,
                CreatedOn  = DateTime.UtcNow,
                Status     = ShiftApplicationStatus.Pending,
            };

            this.FakeDb.Add(shiftApplication);

            this.shiftApplicationService = new ShiftApplicationService(this.GetMockedRepositoryAll());

            // Act
            await this.shiftApplicationService.ApproveShiftApplicationAsync(id);

            // Assert
            Assert.True(shiftApplication.Status == ShiftApplicationStatus.Approved);
        }