public void ShouldAddSuggestion() { // Arrange var mockSuggestionRepository = new Mock <ISuggestionRepository>(); mockSuggestionRepository.Setup(x => x.Get(42)) .Returns(value: null); var mockBookingReposiroty = new Mock <IBookingRepository>(); Suggestion sugg = new Suggestion() { Id = 42, UserId = 1, Name = "dit is een suggestie", NumberOfHours = 8.0, Description = "dit is een beschrijving", Milestone = "dit is een milestone", Type = BookingType.Training }; var sut = new SuggestionsController(mockSuggestionRepository.Object, mockBookingReposiroty.Object); // Act IActionResult actionResult = sut.AddSuggestion(sugg, 1); // Assert Assert.IsNotNull(actionResult); mockSuggestionRepository.Verify(mock => mock.Get(42)); mockSuggestionRepository.Verify(mock => mock.Add(sugg), Times.Once); }
public void Db_AddSuggestion_Test() { //Arrange SuggestionsController controller = new SuggestionsController(this.repoWithTestDBContext); new Suggestion { Id = 1, City = "Borihg", Country = "USA", Description = "Fun places" }; //Act var addSuggestionView = controller.AddSuggestion("Boring", "USA", "Fun place");// as ViewResult; //Assert Assert.True(true); }