public async Task AddShiftAddsShift() { var service = new ShiftService(_client, TestDb, TestContainer); var fixture = new Fixture(); var testShift = fixture.Create <NewShift>(); var userId = fixture.Create <string>(); var res = await service.AddShift(userId, testShift); res.Should().NotBeNullOrEmpty(); var container = _client.GetContainer(TestDb, TestContainer); var shiftResponse = await container.ReadItemAsync <Shift>(res, new PartitionKey(userId)); var shift = shiftResponse.Resource; shift.CrewMate.Should().Be(testShift.CrewMate); shift.Date.Should().Be(testShift.Date); shift.Duration.Should().Be(testShift.Duration); shift.Event.Should().Be(testShift.Event); shift.Id.Should().Be(res); shift.Jobs.Should().BeEmpty(); shift.Location.Should().Be(testShift.Location); shift.Role.Should().Be(testShift.Role); shift.UserId.Should().Be(userId); }
public async Task AddShiftThrowsOnNullShift() { var service = new ShiftService(_client, TestDb, TestContainer); var fixture = new Fixture(); var userId = fixture.Create <string>(); var func = new Func <Task>(() => service.AddShift(userId, null)); await func.Should().ThrowAsync <ArgumentException>(); }
public async Task AddShiftThrowsOnEmptyUserId() { var service = new ShiftService(_client, TestDb, TestContainer); var fixture = new Fixture(); var testJob = fixture.Create <NewShift>(); var func = new Func <Task>(() => service.AddShift(string.Empty, testJob)); await func.Should().ThrowAsync <ArgumentException>(); }
/// <summary> /// Creating the shift, adding the shift to database, as a supervisor/manager /// </summary> /// <param name="startDateTime"></param> /// <param name="endDateTime"></param> /// <param name="numberOfEmployeedNeeded"></param> protected async Task AddShifts(DateTime startDateTime, DateTime endDateTime, int numberOfEmployeedNeeded) { ShiftModel shiftModel = new ShiftModel() { StartTime = startDateTime, EndTime = endDateTime, EmployeesNeeded = numberOfEmployeedNeeded, CreatedBy = LoggedInUser.Id }; ShiftService.AddShift(shiftModel); //signal r sending real time changes if (IsConnected) { await SendMessage(); } }