public void AlbumCountTest() { ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString()); var context = cRUDTestDBContextProvider.GetContext(); var artist = new Artist { ArtistId = 1 }; var album = new Album { AlbumId = 1, ArtistId = 1, Title = "TestAlbumTitle" }; context.Add(artist); context.Add(album); context.SaveChanges(); ArtistBE artistBE = new ArtistBE(cRUDTestDBContextProvider); artistBE.Load(1); Assert.IsTrue(artistBE.AlbumCount == 1); AlbumBE albumBE = new AlbumBE(cRUDTestDBContextProvider); albumBE.New(); albumBE.Title = "TestAlbumTitle"; artistBE.AddToAlbum(albumBE); albumBE.Save(); ArtistBE artistBE2 = new ArtistBE(cRUDTestDBContextProvider); artistBE2.Load(1); Assert.IsTrue(artistBE2.AlbumCount == 2); }
public void AddToAlbumTest() { ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString()); var context = cRUDTestDBContextProvider.GetContext(); var artist = new Artist { ArtistId = 1 }; var album = new Album { AlbumId = 1, Title = "TestAlbumTitle" }; context.Add(artist); context.Add(album); context.SaveChanges(); AlbumBE albumBE = new AlbumBE(cRUDTestDBContextProvider); ArtistBE artistBE = new ArtistBE(cRUDTestDBContextProvider); artistBE.Load(1); albumBE.Load(1); artistBE.AddToAlbum(albumBE); albumBE.Save(); artistBE.Load(1); var AlbumBECollection = artistBE.GetAlbums(); Assert.IsTrue(AlbumBECollection.First().Id == 1); Assert.IsTrue(AlbumBECollection.First().ArtistId == 1); }