Esempio n. 1
0
        public void ArtistAPI_AutoComplete()
        {
            var context = new MockSixteenBarsDb();
            ArtistAPIController ctrl = new ArtistAPIController(context);

            var           result  = ctrl.AutoCompleteName("lil'") as JsonResult;
            List <Artist> results = result.Data as List <Artist>;

            Assert.AreEqual(1, results.Count, "Lil' Kim not found");
            Assert.AreEqual("Lil' Kim", results[0].Name, "Name not Lil' Kim");

            result  = ctrl.AutoCompleteName("dr.") as JsonResult;
            results = result.Data as List <Artist>;
            Assert.AreEqual(1, results.Count, "Dr. Dre not found");
            Assert.AreEqual("Dr. Dre", results[0].Name, "Name not Dr. Dre");

            result  = ctrl.AutoCompleteName("ren$") as JsonResult;
            results = result.Data as List <Artist>;
            Assert.AreEqual(1, results.Count, "Curren$y not found");
            Assert.AreEqual("Curren$y", results[0].Name, "Name not Curren$y");

            result  = ctrl.AutoCompleteName("ay-") as JsonResult;
            results = result.Data as List <Artist>;
            Assert.AreEqual(1, results.Count, "Jay-Z not found");
            Assert.AreEqual("Jay-Z", results[0].Name, "Name not Jay-Z");

            result  = ctrl.AutoCompleteName("The game") as JsonResult;
            results = result.Data as List <Artist>;
            Assert.AreEqual(1, results.Count, "The Game not found");
            Assert.AreEqual("The Game", results[0].Name, "Name not The Game");

            result  = ctrl.AutoCompleteName(":") as JsonResult;
            results = result.Data as List <Artist>;
            Assert.AreEqual(0, results.Count, ": should not return any results");

            result  = ctrl.AutoCompleteName(";") as JsonResult;
            results = result.Data as List <Artist>;
            Assert.AreEqual(0, results.Count, "; should not return any results");

            result  = ctrl.AutoCompleteName("\\") as JsonResult;
            results = result.Data as List <Artist>;
            Assert.AreEqual(0, results.Count, "\\ should not return any results");

            result  = ctrl.AutoCompleteName("\"") as JsonResult;
            results = result.Data as List <Artist>;
            Assert.AreEqual(0, results.Count, "\" should not return any results");


            result  = ctrl.AutoCompleteName("gam") as JsonResult;
            results = result.Data as List <Artist>;
            Assert.AreEqual(2, results.Count);
            Assert.AreEqual("Childish Gambino", results[0].Name, "Name not Childish Gambino");
            Assert.AreEqual("The Game", results[1].Name, "Name not The Game");
        }
Esempio n. 2
0
        public void Album_Edit()
        {
            ISixteenBarsDb  mockDb      = new MockSixteenBarsDb();
            AlbumController ctrl        = new AlbumController(mockDb);
            AlbumViewModel  editedAlbum = new AlbumViewModel()
            {
                Id          = 1,
                Title       = "Because of the interwebs",
                ReleaseDate = new DateTime(2015, 5, 4),
                ArtistId    = 10
            };

            ctrl.Edit(editedAlbum);
            Assert.AreEqual(editedAlbum.Title, mockDb.Albums.Find(1).Title, "Title not changed to 'Because of the interwebs'.");
            Assert.AreEqual(editedAlbum.ReleaseDate, mockDb.Albums.Find(1).ReleaseDate, "Release date not changed to '5/4/15'.");
            Assert.AreEqual(editedAlbum.ArtistId, mockDb.Albums.Find(1).Artist.Id, "Artist not changed to 'Dr. Dre'.");

            editedAlbum = new AlbumViewModel()
            {
                Id          = 1,
                Title       = ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./",
                ReleaseDate = new DateTime(1993, 11, 23),
                ArtistName  = ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./"
            };
            ctrl.Edit(editedAlbum);
            Assert.AreEqual(editedAlbum.Title, mockDb.Albums.Find(1).Title, "Title not changed to .~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./");
            Assert.AreEqual(editedAlbum.ReleaseDate, mockDb.Albums.Find(1).ReleaseDate, "Release date not changed to 11/23/93.");
            Assert.AreEqual(editedAlbum.ArtistName, mockDb.Albums.Find(1).Artist.Name, "Artist not chnaged to .~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./");

            editedAlbum = new AlbumViewModel()
            {
                Id          = 1,
                Title       = "The Blueprint2",
                ReleaseDate = new DateTime(2002, 9, 11),
                ArtistId    = 9
            };
            ctrl.Edit(editedAlbum);
            Assert.AreEqual(editedAlbum.Title, mockDb.Albums.Find(1).Title, "Title not changed to The Blueprint2.");
            Assert.AreEqual(editedAlbum.ReleaseDate, mockDb.Albums.Find(1).ReleaseDate, "Release date not changed to 9/11/02.");
            Assert.AreEqual("50 Cent", mockDb.Albums.Find(1).Artist.Name, "Artist not changed to 50 Cent");


            //editedAlbum = new AlbumViewModel()
            //{
            //    Id = 1,
            //    Title = "Because the Internet",
            //    ReleaseDate = new DateTime(2013, 12, 3),
            //    ArtistName = "Childish Gambino"
            //};
            //ctrl.Edit(editedAlbum);
            //Assert.AreEqual(1,mockDb.Artists.f, "Because the Internet was created twice");
        }
Esempio n. 3
0
        public void Track_Index()
        {
            ISixteenBarsDb  mockDb = new MockSixteenBarsDb();
            TrackController ctrl   = new TrackController(mockDb);

            var result = ctrl.Index() as ViewResult;

            Assert.IsInstanceOfType(result.ViewData.Model, typeof(List <TrackIndexViewModel>));
            var tracks = (List <TrackIndexViewModel>)result.ViewData.Model;

            Assert.AreEqual(5, tracks.Count, "More than or less than 5 tracks.");

            Assert.AreEqual("Bandz A Make Her Dance", tracks[0].Title, "Track title not 'Bandz A Make Her Dance'");
            Assert.AreEqual(true, tracks[0].IsDeleteable, "Track title not 'Bandz A Make Her Dance' is not deleteable");
            Assert.AreEqual("IV. Sweatpants", tracks[1].Title, "Track title not 'IV. Sweatpants'");
            Assert.AreEqual(false, tracks[1].IsDeleteable, "Track title not 'IV. Sweatpants' is not deleteable");
            Assert.AreEqual("King Sh*t", tracks[2].Title, "Track title not 'King Sh*t'");
            Assert.AreEqual(true, tracks[2].IsDeleteable, "Track title not 'King Sh*t' is deleteable");
            Assert.AreEqual("Light Up", tracks[3].Title, "Track title not 'Light Up'");
            Assert.AreEqual(false, tracks[3].IsDeleteable, "Track title not 'Light Up' is not deleteable");
            Assert.AreEqual("Wetter Than Tsunami", tracks[4].Title, "Track title not 'Wetter Than Tsunami'");
            Assert.AreEqual(true, tracks[4].IsDeleteable, "Track title not 'Wetter Than Tsunami' is deleteable");
        }
Esempio n. 4
0
        public void Album_Create()
        {
            ISixteenBarsDb  mockDb   = new MockSixteenBarsDb();
            AlbumController ctrl     = new AlbumController(mockDb);
            Album           newAlbum = new Album()
            {
                Id          = 5,
                Title       = "Doggystyle",
                ReleaseDate = new DateTime(1993, 11, 23),
                Artist      = new Artist()
                {
                    Id   = 11,
                    Name = "Snoop Doggy Dogg"
                }
            };

            ctrl.Create(newAlbum);
            Assert.AreEqual(newAlbum.Title, mockDb.Albums.Find(5).Title, "Doggystyle not added.");
            Assert.AreEqual(newAlbum.ReleaseDate, mockDb.Albums.Find(5).ReleaseDate, "Doggystyle release date not 11/23/93.");
            Assert.AreEqual(newAlbum.Artist.Name, mockDb.Albums.Find(5).Artist.Name, "Snoop Doggy Dogg not added as artist for Doggystyle.");

            newAlbum = new Album()
            {
                Id          = 6,
                Title       = ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./",
                ReleaseDate = new DateTime(1993, 11, 23),
                Artist      = new Artist()
                {
                    Id   = 12,
                    Name = ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./"
                }
            };
            ctrl.Create(newAlbum);
            Assert.AreEqual(newAlbum.Title, mockDb.Albums.Find(6).Title, ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./ not added.");
            Assert.AreEqual(newAlbum.ReleaseDate, mockDb.Albums.Find(6).ReleaseDate, ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./ release date not 11/23/93.");
            Assert.AreEqual(newAlbum.Artist.Name, mockDb.Albums.Find(6).Artist.Name, ".~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./ not added as artist for .~`!@#$%^&*()_+-={}|:\"<>?[]\\;',./.");

            newAlbum = new Album()
            {
                Id          = 7,
                Title       = "The Blueprint",
                ReleaseDate = new DateTime(2001, 9, 11),
                Artist      = new Artist()
                {
                    Id = 1
                }
            };
            ctrl.Create(newAlbum);
            Assert.AreEqual(newAlbum.Title, mockDb.Albums.Find(7).Title, "The Blueprint not added.");
            Assert.AreEqual(newAlbum.ReleaseDate, mockDb.Albums.Find(7).ReleaseDate, "The Blueprint release date not 9/11/01.");
            Assert.AreEqual("Jay-Z", mockDb.Albums.Find(7).Artist.Name, "Jay-Z not added as artist for The Blueprint.");


            newAlbum = new Album()
            {
                Id          = 8,
                Title       = "Because the Internet",
                ReleaseDate = new DateTime(2013, 12, 3),
                Artist      = new Artist()
                {
                    Id = 3
                }
            };
            ctrl.Create(newAlbum);
            Assert.IsNull(mockDb.Albums.Find(8), "Because the Internet was created twice");

            newAlbum = new Album()
            {
                Id          = 9,
                Title       = "Because the Internet",
                ReleaseDate = new DateTime(2013, 12, 3),
                Artist      = new Artist()
                {
                    Id   = 12,
                    Name = "Childish Gambino"
                }
            };
            ctrl.Create(newAlbum);
            Assert.IsNull(mockDb.Albums.Find(9), "Because the Internet was created twice");
            Assert.IsNull(mockDb.Artists.Find(12), "Childish Gambino was created twice");

            newAlbum = new Album()
            {
                Id          = 9,
                Title       = "The Blueprint",
                ReleaseDate = new DateTime(2015, 5, 4),
                Artist      = new Artist()
                {
                    Id   = 12,
                    Name = "Jay-Z Imposter"
                }
            };
            ctrl.Create(newAlbum);
            Assert.AreEqual(newAlbum.Title, mockDb.Albums.Find(9).Title, "The Blueprint from different artist not added.");
            Assert.AreEqual(newAlbum.ReleaseDate, mockDb.Albums.Find(9).ReleaseDate, "The Blueprint from different artist release date not 5/4/15.");
            Assert.AreEqual("Jay-Z Imposter", mockDb.Albums.Find(9).Artist.Name, "The Jay-Z Imposter not added as artist for The other Blueprint album.");
        }
Esempio n. 5
0
        public void Track_Create()
        {
            MockSixteenBarsDb mockDb = new MockSixteenBarsDb();
            TrackController   ctrl   = new TrackController(mockDb);

            TrackViewModel newTrack = new TrackViewModel()
            {
                Title       = "Shabba",
                AlbumTitle  = "Trap Lord",
                ArtistName  = "A$AP Ferg",
                ReleaseDate = new DateTime(2013, 8, 20)
            };


            ctrl.Create(newTrack);

            Track foundTrack = mockDb.Tracks.SingleOrDefault(t => t.Title == newTrack.Title);

            Assert.AreEqual(newTrack.Title, foundTrack.Title, "Title not Shabba");
            Assert.AreEqual(newTrack.AlbumTitle, foundTrack.Album.Title, "Name not Trap Lord");
            Assert.AreEqual(newTrack.ArtistName, foundTrack.Album.Artist.Name, "Name not A$AP Ferg");

            newTrack = new TrackViewModel()
            {
                Title       = "She Don't Want A Man",
                ArtistName  = "Curren$y",
                AlbumTitle  = "Weekend At Burnie's",
                ReleaseDate = new DateTime(2011, 6, 28)
            };


            ctrl.Create(newTrack);

            foundTrack = mockDb.Tracks.SingleOrDefault(t => t.Title == newTrack.Title);
            Int32 cntArtists = mockDb.Artists.Where(a => a.Name == newTrack.ArtistName.Trim()).Count();

            Assert.AreEqual(newTrack.Title, foundTrack.Title, "Title not She Don't Want A Man");
            Assert.AreEqual(newTrack.AlbumTitle, foundTrack.Album.Title, "Name not Weekend At Burnie's");
            Assert.AreEqual(newTrack.ArtistName, foundTrack.Album.Artist.Name, "Name not Curren$y");
            Assert.AreEqual(1, cntArtists, "Artist Currenc$y was duplicated.");


            newTrack = new TrackViewModel()
            {
                Title       = "I.Crawl",
                ArtistName  = "Childish Gambino",
                AlbumTitle  = "Because The Internet",
                ReleaseDate = new DateTime(2014, 3, 1)
            };
            ctrl.Create(newTrack);

            foundTrack = mockDb.Tracks.SingleOrDefault(t => t.Title == newTrack.Title);
            cntArtists = mockDb.Artists.Where(a => a.Name == newTrack.ArtistName.Trim()).Count();
            Int32 cntAlbums = mockDb.Albums.Where(a => a.Title == newTrack.AlbumTitle.Trim()).Count();

            Assert.AreEqual(newTrack.Title, foundTrack.Title, "Title not I.Crawl");
            Assert.AreEqual(newTrack.AlbumTitle, foundTrack.Album.Title, "Name not Because The Internet");
            Assert.AreEqual(newTrack.ArtistName, foundTrack.Album.Artist.Name, "Name not Childish Gambino");
            Assert.AreEqual(1, cntArtists, "Artist Childish Gambino was duplicated.");
            Assert.AreEqual(1, cntAlbums, "Album Because The Internet was duplicated.");
        }
Esempio n. 6
0
        public void Track_Edit()
        {
            MockSixteenBarsDb db = new MockSixteenBarsDb();

            TrackController ctrl = new TrackController(db);


            Track editted = db.Tracks.Find(1);

            Assert.AreEqual(editted.Id, 1, "Track Id not 1");
            Assert.AreEqual(editted.Title, "IV. Sweatpants", "Track title not 'IV. Sweatpants'");


            String   newTitle = "Push It", newArtist = "Salt-n-Pepa", newAlbumTitle = "Hot, Cool & Vicious";
            DateTime newDate = new DateTime(1992, 12, 8);

            editted.Title             = newTitle;
            editted.Album.Artist.Name = newArtist;
            editted.Album.Title       = newAlbumTitle;
            editted.ReleaseDate       = newDate;
            ctrl.Edit(editted);

            Track actual = db.Tracks.Find(1);

            Assert.AreEqual(actual.Id, 1, "Track Id not 1");
            Assert.AreEqual(actual.Title, newTitle, "Track title not 'Push It'");
            Assert.AreEqual(actual.Album.Artist.Name, newArtist, "Track artist not 'Salt-n-Pepa'");
            Assert.AreEqual(actual.Album.Title, newAlbumTitle, "Track album title not 'Hot, Cool & Vicious'");
            Assert.AreEqual(actual.ReleaseDate, newDate, "Track release date not '12/8/1992'");



            editted = db.Tracks.Find(2);
            Assert.AreEqual(editted.Id, 2, "Track Id not 2");
            Assert.AreEqual(editted.Title, "Light Up", "Track title not 'Light Up'");


            newTitle = "How to be the Man"; newArtist = "Riff Raff"; newAlbumTitle = "Neon Icon";
            newDate  = new DateTime(2014, 5, 1);


            editted.Album.Artist.Name = newArtist;
            editted.Album.Title       = newAlbumTitle;
            editted.ReleaseDate       = newDate;
            ctrl.Edit(editted);

            actual = db.Tracks.Find(2);

            Assert.AreEqual(actual.Id, 2, "Track Id not 2");
            Assert.AreEqual(actual.Title, editted.Title, "Track title not 'Light Up'");
            Assert.AreEqual(actual.Album.Artist.Name, newArtist, "Track artist not 'Riff Raff'");
            Assert.AreEqual(actual.Album.Title, newAlbumTitle, "Track album title not 'Neon Icon'");
            Assert.AreEqual(actual.ReleaseDate, newDate, "Track release date not '5/1/2014'");

            editted = db.Tracks.Find(5);
            Assert.AreEqual(editted.Id, 5, "Track Id not 5");
            Assert.AreEqual(editted.Title, "Bandz A Make Her Dance", "Track title not 'Bandz A Make Her Dance'");


            newTitle = "How to be the Man"; newArtist = "Riff Raff"; newAlbumTitle = "Neon Icon";
            newDate  = new DateTime(2014, 5, 1);


            editted.Album.Artist.Name = newArtist;
            ctrl.Edit(editted);

            actual = db.Tracks.Find(5);

            Assert.AreEqual(actual.Id, 5, "Track Id not 5");
            Assert.AreEqual(actual.Title, editted.Title, "Track title not 'Bandz A Make Her Dance'");
            Assert.AreEqual(actual.Album.Artist.Name, newArtist, "Track artist not 'Riff Raff'");
            Assert.AreEqual(actual.Album.Title, editted.Album.Title, "Track album title not 'Stay Trippy'");
            Assert.AreEqual(actual.ReleaseDate, editted.ReleaseDate, "Track release date not '8/27/2013'");



            editted = db.Tracks.Find(4);
            Assert.AreEqual(editted.Id, 4, "Track Id not 4");
            Assert.AreEqual(editted.Title, "King Sh*t", "Track title not 'King Sh*t'");


            newTitle = "How to be the Man"; newArtist = "Riff Raff"; newAlbumTitle = "Neon Icon";
            newDate  = new DateTime(2014, 5, 1);


            editted.Album.Title = newAlbumTitle;
            ctrl.Edit(editted);

            actual = db.Tracks.Find(4);

            Assert.AreEqual(actual.Id, 4, "Track Id not 4");
            Assert.AreEqual(actual.Title, editted.Title, "Track title not 'King Sh*t'");
            Assert.AreEqual(actual.Album.Artist.Name, editted.Album.Artist.Name, "Track artist not 'Yo Gotti'");
            Assert.AreEqual(actual.Album.Title, newAlbumTitle, "Track album title not 'Neon Icon'");
            Assert.AreEqual(actual.ReleaseDate, editted.ReleaseDate, "Track release date not '8/27/2013'");
        }