public async Task GetIncompleteItemsAsyncForGivenDateShouldReturnElementsCorrectly() { var options = new DbContextOptionsBuilder <AspNetCoreTodo.Data.ApplicationDbContext>().UseInMemoryDatabase(databaseName: "Test_AddNewItem9").Options; var fakeUser = CreateFakeUsers(0); using (var context = new ApplicationDbContext(options)) { var service = new TodoItemService(context); int counter = 4; while (counter > 0) { if (counter % 2 == 0) { await service.AddItemAsync(new TodoItem { Title = "Tarea" + counter, Address = "Calle Sarasa 202" + counter + " CABA", DueAt = DateTime.Now.AddDays(counter) }, fakeUser); } else { await service.AddItemAsync(new TodoItem { Title = "Tarea" + counter, Address = "Calle Sarasa 202" + counter + " CABA", DueAt = DateTime.Now.AddHours(counter) }, fakeUser); } counter--; } } using (var context = new ApplicationDbContext(options)) { var service = new TodoItemService(context); TodoItem[] todoItem = await service.GetIncompleteItemsWithDateAsync(fakeUser, DateTime.Now); Assert.True(todoItem.Length == 2); } }
public async Task GetIncompleteItemsAsyncForGivenDateWithEmptyResultShouldReturnEmpty() { var options = new DbContextOptionsBuilder <AspNetCoreTodo.Data.ApplicationDbContext>().UseInMemoryDatabase(databaseName: "Test_AddNewItem10").Options; var fakeUser = CreateFakeUsers(0); using (var context = new ApplicationDbContext(options)) { var service = new TodoItemService(context); await service.AddItemAsync(new TodoItem { Title = "Tarea1", Address = "Calle Sarasa 2020 CABA", DueAt = DateTime.Now.AddDays(5) }, fakeUser); } using (var context = new ApplicationDbContext(options)) { var service = new TodoItemService(context); TodoItem[] todoItem = await service.GetIncompleteItemsWithDateAsync(fakeUser, DateTime.Now); Assert.Empty(todoItem); } }