public void TrackCountTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context   = cRUDTestDBContextProvider.GetContext();
            var mediaType = new MediaType
            {
                MediaTypeId = 1
            };
            var track = new Track {
                TrackId = 1, MediaTypeId = 1, Name = "TestTrackName"
            };

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

            MediaTypeBE mediaTypeBE = new MediaTypeBE(cRUDTestDBContextProvider);

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

            TrackBE trackBE = new TrackBE(cRUDTestDBContextProvider);

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

            MediaTypeBE mediaTypeBE2 = new MediaTypeBE(cRUDTestDBContextProvider);

            mediaTypeBE2.Load(1);
            Assert.IsTrue(mediaTypeBE2.TrackCount == 2);
        }
        public void AddToTrackTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context   = cRUDTestDBContextProvider.GetContext();
            var mediaType = new MediaType
            {
                MediaTypeId = 1
            };
            var track = new Track {
                TrackId = 1, Name = "TestTrackName"
            };

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

            TrackBE     trackBE     = new TrackBE(cRUDTestDBContextProvider);
            MediaTypeBE mediaTypeBE = new MediaTypeBE(cRUDTestDBContextProvider);

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

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

            Assert.IsTrue(TrackBECollection.First().Id == 1);
            Assert.IsTrue(TrackBECollection.First().MediaTypeId == 1);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
0
        public void SaveValidIdTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            var context = cRUDTestDBContextProvider.GetContext();
            var track   = new Track {
                TrackId = 1
            };

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

            TrackBE trackBE = new TrackBE(cRUDTestDBContextProvider);

            trackBE.Load(1);
            trackBE.Name         = "TestTrackName";
            trackBE.Composer     = "TestComposer";
            trackBE.Milliseconds = 1000;
            trackBE.Save();

            TrackBE trackBE2 = new TrackBE(cRUDTestDBContextProvider);

            trackBE2.Load(1);
            Assert.IsTrue(trackBE2.Id == 1);
            Assert.IsTrue(trackBE2.Name == "TestTrackName");
            Assert.IsTrue(trackBE2.Composer == "TestComposer");
            Assert.IsTrue(trackBE2.Milliseconds == 1000);
        }
Пример #6
0
        public void SaveWithoutIdTest()
        {
            ICRUDTestDBContextProvider cRUDTestDBContextProvider = new CRUDTestDBContextProvider(Guid.NewGuid().ToString());
            TrackBE trackBE = new TrackBE(cRUDTestDBContextProvider);

            trackBE.New();
            trackBE.Name = "TestTrackName";
            trackBE.Save();

            Assert.IsTrue(trackBE.Id != default);
        }