public async Task GetAllShiftsThrowsOnEmptyUser() { var service = new ShiftService(_client, TestDb, TestContainer); var func = new Func <Task>(() => service.GetAllShifts(string.Empty)); await func.Should().ThrowAsync <ArgumentException>(); }
public async Task GetAllShiftsGetsAllUsersShifts() { var service = new ShiftService(_client, TestDb, TestContainer); var fixture = new Fixture(); var userId = fixture.Create <string>(); var usersShifts = fixture.Build <Shift>() .With(s => s.UserId, userId) .CreateMany(); var otherShifts = fixture.CreateMany <Shift>(); await _client.CreateDatabaseIfNotExistsAsync(TestDb); await _client.GetDatabase(TestDb).CreateContainerIfNotExistsAsync(TestContainer, "/userId"); foreach (var shift in usersShifts) { await _client.GetContainer(TestDb, TestContainer).CreateItemAsync(shift, new PartitionKey(shift.UserId)); } foreach (var shift in otherShifts) { await _client.GetContainer(TestDb, TestContainer).CreateItemAsync(shift, new PartitionKey(shift.UserId)); } var actual = await service.GetAllShifts(userId); actual.Should().BeEquivalentTo(usersShifts); }