public void CallArtistServiceMethodGetArtists_WhenInvoked() { // Arrange var createService = new Mock <ICreationService>(); var artistService = new Mock <IArtistService>(); var albumService = new Mock <IAlbumService>(); var genreService = new Mock <IGenreService>(); var artist = new Artist() { Name = "Artist Name" }; var artistCollection = new List <Artist>() { artist }; artistService.Setup(x => x.GetArtists()).Returns(() => artistCollection.AsQueryable()); var sut = new CreateController( createService.Object, artistService.Object, albumService.Object, genreService.Object); // Act sut.CreateAlbum(); // Assert artistService.Verify(x => x.GetArtists(), Times.Once); }
public void CallCreateServiceMethodCreateAlbumOnce_WhenInvoked() { // Arrange var createService = new Mock <ICreationService>(); var artistService = new Mock <IArtistService>(); var albumService = new Mock <IAlbumService>(); var genreService = new Mock <IGenreService>(); createService.Setup(x => x.CreateGenre(It.IsAny <string>())); var sut = new CreateController( createService.Object, artistService.Object, albumService.Object, genreService.Object); var model = new CreateAlbumViewModel() { Title = "Album Name", Artist = "Artist Name", CoverUrl = "CoverUrl" }; // Act sut.CreateAlbum(model); // Assert createService.Verify(x => x.CreateAlbum(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once); }