public async Task GetAsyncTestUnhappy() { // Arrange var mockSuggestionRepository = GetDefaultISuggestionRepositoryInstance(); var mockUserRepository = GetDefaultIUserRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); int suggestionId = 1; var service = new SuggestionService(mockSuggestionRepository.Object, mockUnitOfWork.Object, mockUserRepository.Object); // Act SuggestionResponse result = await service.GetByIdAsync(suggestionId); var message = result.Message; // Assert message.Should().Be("Suggestion not found"); }
public async Task GetAsyncTestHappy() { // Arrange var mockSuggestionRepository = GetDefaultISuggestionRepositoryInstance(); var mockUserRepository = GetDefaultIUserRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); Suggestion suggestion = new Suggestion(); int suggestionId = 1; suggestion.Id = suggestionId; mockSuggestionRepository.Setup(r => r.FindById(suggestionId)) .Returns(Task.FromResult <Suggestion>(suggestion)); var service = new SuggestionService(mockSuggestionRepository.Object, mockUnitOfWork.Object, mockUserRepository.Object); // Act SuggestionResponse result = await service.GetByIdAsync(suggestionId); // Assert Assert.AreEqual(suggestion, result.Resource); }