Ejemplo n.º 1
0
        public void TrackCountTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context = cRUDTestDBContextProvider.GetContext();
            var album   = new Album
            {
                Title   = "TestAlbumTitle",
                AlbumId = 1
            };
            var track = new Track {
                TrackId = 1, AlbumId = 1, Name = "TestTrackName"
            };

            context.Add(album);
            context.Add(track);
            context.SaveChanges();

            AlbumBE albumBE = new AlbumBE(cRUDTestDBContextProvider);

            albumBE.Load(1);
            Assert.IsTrue(albumBE.TrackCount == 1);

            TrackBE trackBE = new TrackBE(cRUDTestDBContextProvider);

            trackBE.New();
            trackBE.Name = "TestName";
            albumBE.AddToTrack(trackBE);
            trackBE.Save();

            AlbumBE albumBE2 = new AlbumBE(cRUDTestDBContextProvider);

            albumBE2.Load(1);
            Assert.IsTrue(albumBE2.TrackCount == 2);
        }
Ejemplo n.º 2
0
        public void AddToTrackTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context = cRUDTestDBContextProvider.GetContext();
            var album   = new Album
            {
                Title   = "TestAlbumTitle",
                AlbumId = 1
            };
            var track = new Track {
                TrackId = 1, Name = "TestTrackName"
            };

            context.Add(album);
            context.Add(track);
            context.SaveChanges();

            TrackBE trackBE = new TrackBE(cRUDTestDBContextProvider);
            AlbumBE albumBE = new AlbumBE(cRUDTestDBContextProvider);

            albumBE.Load(1);
            trackBE.Load(1);
            albumBE.AddToTrack(trackBE);
            trackBE.Save();

            albumBE.Load(1);
            var TrackBECollection = albumBE.GetTracks();

            Assert.IsTrue(TrackBECollection.First().Id == 1);
            Assert.IsTrue(TrackBECollection.First().AlbumId == 1);
        }