Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }