public async void GetAsync_GivenCategoriesExist_ReturnsEnumerableCategories() { var categoriesToReturn = new CategoryDTO[] { new CategoryDTO { Id = 1, Name = "This is the first" }, new CategoryDTO { Id = 2, Name = "This is the second" }, new CategoryDTO { Id = 3, Name = "This is the third" } }; categoryRepositoryMock.Setup(c => c.ReadAsync()).ReturnsAsync(categoriesToReturn); using (var logic = new CategoryLogic(categoryRepositoryMock.Object, projectRepositoryMock.Object)) { var results = await logic.GetAsync(); Assert.Equal(categoriesToReturn, results); categoryRepositoryMock.Verify(c => c.ReadAsync()); } }
public async void GetAsync_GivenExistingCategoryId_ReturnsCategory() { var categoryToReturn = new CategoryDTO { Id = 3, Name = "This is a Category" }; categoryRepositoryMock.Setup(c => c.FindAsync(3)).ReturnsAsync(categoryToReturn); using (var logic = new CategoryLogic(categoryRepositoryMock.Object, projectRepositoryMock.Object)) { var result = await logic.GetAsync(3); Assert.Equal(categoryToReturn, result); categoryRepositoryMock.Verify(c => c.FindAsync(3)); } }