public void AddToTrackTest() { ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString()); var context = cRUDTestDBContextProvider.GetContext(); var genre = new Genre { GenreId = 1 }; var track = new Track { TrackId = 1, Name = "TestTrackName" }; context.Add(genre); context.Add(track); context.SaveChanges(); TrackBE trackBE = new TrackBE(cRUDTestDBContextProvider); GenreBE genreBE = new GenreBE(cRUDTestDBContextProvider); trackBE.Load(1); genreBE.Load(1); genreBE.AddToTrack(trackBE); trackBE.Save(); genreBE.Load(1); var TrackBECollection = genreBE.GetTracks(); Assert.IsTrue(TrackBECollection.First().Id == 1); Assert.IsTrue(TrackBECollection.First().GenreId == 1); }
public void GetTracksTest() { ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString()); var context = cRUDTestDBContextProvider.GetContext(); var genre = new Genre { GenreId = 1 }; var genre2 = new Genre { GenreId = 2 }; var track = new Track { TrackId = 1, GenreId = 1, Name = "TestTrackName" }; context.Add(genre); context.Add(genre2); context.Add(track); context.SaveChanges(); GenreBE genreBE = new GenreBE(cRUDTestDBContextProvider); GenreBE genreBE2 = new GenreBE(cRUDTestDBContextProvider); genreBE.Load(1); genreBE2.Load(2); var TrackBECollection = genreBE.GetTracks(); Assert.IsTrue(TrackBECollection.First().GetType() == typeof(TrackBE)); Assert.IsTrue(TrackBECollection.First().Name == "TestTrackName"); Assert.IsTrue(TrackBECollection.First().Id == 1); Assert.IsTrue(genreBE2.GetTracks().IsNullOrEmpty()); }
public void LoadValidIdTest() { ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString()); var context = cRUDTestDBContextProvider.GetContext(); var genre = new Genre { Name = "TestGenreName", GenreId = 1 }; var genre2 = new Genre { GenreId = 2 }; context.Add(genre); context.Add(genre2); context.SaveChanges(); GenreBE genreBE = new GenreBE(cRUDTestDBContextProvider); genreBE.Load(1); Assert.IsTrue(genreBE.Id == 1); Assert.IsTrue(genreBE.Name == "TestGenreName"); GenreBE genreBE2 = new GenreBE(cRUDTestDBContextProvider); genreBE2.Load(2); Assert.IsTrue(genreBE2.Id == 2); }
public void TrackCountTest() { ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString()); var context = cRUDTestDBContextProvider.GetContext(); var genre = new Genre { GenreId = 1 }; var track = new Track { TrackId = 1, GenreId = 1, Name = "TestTrackName" }; context.Add(genre); context.Add(track); context.SaveChanges(); GenreBE genreBE = new GenreBE(cRUDTestDBContextProvider); genreBE.Load(1); Assert.IsTrue(genreBE.TrackCount == 1); TrackBE trackBE = new TrackBE(cRUDTestDBContextProvider); trackBE.New(); trackBE.Name = "TestName"; genreBE.AddToTrack(trackBE); trackBE.Save(); GenreBE genreBE2 = new GenreBE(cRUDTestDBContextProvider); genreBE2.Load(1); Assert.IsTrue(genreBE2.TrackCount == 2); }
public void ToStringTest() { ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString()); var context = cRUDTestDBContextProvider.GetContext(); var genre = new Genre { GenreId = 1, Name = "TestGenreName" }; context.Add(genre); context.SaveChanges(); GenreBE genreBE = new GenreBE(cRUDTestDBContextProvider); genreBE.Load(1); Assert.IsTrue(genreBE.ToString().Equals("GenreName: TestGenreName")); }