public async Task GetAllToDoItemsAsync_Returns_AllToDoRecordsInDatabase() { using (ToDoContext dbContext = RepositoryTestHelper.NewInMemoryToDoContext()) { await RepositoryTestHelper.SeedData(dbContext); var toDoRepository = new ToDoRepository(dbContext, _mapper); var result = await toDoRepository.GetAllToDoItemsAsync(); var expectedResult = RepositoryTestHelper.GetMockToDoItemList(); result.Should().BeEquivalentTo(expectedResult); } }
public async Task GetToDoItemById_Returns_ToDoRecordFromDatabase() { using (ToDoContext dbContext = RepositoryTestHelper.NewInMemoryToDoContext()) { await RepositoryTestHelper.SeedData(dbContext); var todoRepository = new ToDoRepository(dbContext, _mapper); var result = await todoRepository.GetToDoItemByIdAsync(1); var expectedResult = RepositoryTestHelper.GetMockToDoItemList() .Where(x => x.Id == 1) .Select(x => new ToDoModel { Summary = x.Summary, Description = x.Description, Completed = x.Completed }) .FirstOrDefault(); var actualResult = await todoRepository.GetToDoItemByIdAsync(1); actualResult.Should().BeEquivalentTo(expectedResult); } }