public async Task TryGetAllLoggedDaysAsync_ReturnsAllLoggedDays() { // arrange var service = new TrackerLogService(_database, _logger); int trackerId = 1; // act var loggedDays = await service.TryGetAllLoggedDaysAsync(trackerId); // assert Assert.Equal(4, loggedDays.Count()); }
public async Task TryGetAllLoggedDaysAsync_NewTrackerId_ReturnsEmpty() { // arrange var service = new TrackerLogService(_database, _logger); int trackerId = 100; // act var loggedDays = await service.TryGetAllLoggedDaysAsync(trackerId); // assert Assert.Empty(loggedDays); }
public async Task TryBulkAddEntriesAsync_ExistingTrackerId_AddsToDb() { // arrange var service = new TrackerLogService(_database, _logger); int trackerId = 3; // tracker with no existing logged days var days = new[] { new DateTime(2020, 1, 1), new DateTime(2020, 2, 2), DateTime.Now }; // act await service.TryBulkAddEntriesAsync(days, trackerId); var loggedDays = (await service.TryGetAllLoggedDaysAsync(trackerId)) .Select(day => day.Date) .OrderBy(day => day); // assert Assert.Equal(days, loggedDays); }