public async Task Create_CreateArtistShouldAddCorrectly() { //Arrange var artist1 = new Artist("Trivium", 4, "Metal", "Kalifornia"); var mockRepository = new ArtistRepositoryMock(); var controller = new ArtistsController(mockRepository); //Act await controller.Create(artist1); //Assert var artist = await mockRepository.GetById("1"); Assert.Equal("Trivium", artist.Name); }
public async Task Delete_RemoveArtistShouldDecreaseListCount() { //Arrange var artist1 = new Artist("Trivium", 4, "Metal", "Kalifornia"); var artist2 = new Artist("Metallica", 4, "Metal", "Detroit"); var mockRepository = new ArtistRepositoryMock(); var controller = new ArtistsController(mockRepository); await controller.Create(artist1); await controller.Create(artist2); //Act await controller.DeleteConfirmed(1); //Assert var artists = await mockRepository.GetAll() as List <Artist>; Assert.Equal(1, artists.Count); }
public async Task Edit_CorrectUpdateShouldEditArtist() { //Arrange var artist1 = new Artist("Trivium", 4, "Metal", "Kalifornia"); var artist2 = new Artist("Metallica", 4, "Metal", "Detroit"); var mockRepository = new ArtistRepositoryMock(); var controller = new ArtistsController(mockRepository); await controller.Create(artist1); await controller.Create(artist2); //Act artist2.Name = "Megadeth"; await controller.Edit(1); //Assert var artist = await mockRepository.GetById("2"); Assert.Equal("Megadeth", artist.Name); }