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); }
public void ApproveShiftApplicationShouldThrowIfGivenApplicationDoesNotExist() { const string id = "Test"; // Arrange this.shiftApplicationService = new ShiftApplicationService(this.GetMockedRepositoryAll()); // Act // Assert Assert.ThrowsAsync <ArgumentException>(() => this.shiftApplicationService.ApproveShiftApplicationAsync(id)); }
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; }
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); }
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; }
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); }
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); }
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)); }
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); }
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); }