Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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);
        }