예제 #1
0
        public async Task GetUsersShiftsWithDeclaredSwapRequestsAsyncShouldReturnAllPendingShiftsIfEverythingIsCorrect()
        {
            const int    expectedCount = 2;
            const string businessId    = "Test";
            const string userId        = "Test";

            // Arrange
            var group = new Group {
                BusinessId = businessId
            };
            var shiftChange = new ShiftChange {
                OriginalEmployee = new EmployeeGroup {
                    UserId = userId
                }
            };

            var shift = new Shift()
            {
                Start          = this.start,
                End            = this.end,
                ShiftCreatorId = ShiftCreatorId,
                GroupId        = GroupId,
                Description    = Description,
                BonusPayment   = BonusPayment,
                ShiftStatus    = ShiftStatus.Pending,
                Group          = group,
            };

            shift.ShiftChanges.Add(shiftChange);

            var shift2 = new Shift()
            {
                Start          = this.start,
                End            = this.end,
                ShiftCreatorId = ShiftCreatorId,
                GroupId        = GroupId,
                Description    = Description,
                BonusPayment   = BonusPayment,
                ShiftStatus    = ShiftStatus.Pending,
                Group          = group,
            };

            shift2.ShiftChanges.Add(shiftChange);

            this.FakeDb.Add(shift);
            this.FakeDb.Add(shift2);

            this.shiftService = new ShiftService(this.GetMockedRepositoryReturningAllAsNoTracking());

            // Act
            var pendingShifts = await this.shiftService.GetUsersShiftsWithDeclaredSwapRequestsAsync <ShiftTestViewModel>(businessId, userId);

            // Assert
            Assert.NotEmpty(pendingShifts);
            Assert.Equal(expectedCount, pendingShifts.Count());
        }
예제 #2
0
        public async Task <string> CreateShiftChangeAsync(string shiftId, string originalEmployeeId, string candidateEmployeeId)
        {
            var shiftChange = new ShiftChange()
            {
                ShiftId            = shiftId,
                OriginalEmployeeId = originalEmployeeId,
                PendingEmployeeId  = candidateEmployeeId,
                Status             = ShiftApplicationStatus.Pending,
            };

            await this.shiftChangeRepository.AddAsync(shiftChange);

            await this.shiftChangeRepository.SaveChangesAsync();

            return(shiftChange.Id);
        }