예제 #1
0
        public void TestAppInvalidWhenNoMusicController()
        {
            MusicApp app = new MusicApp();

            TestInvalidApp(app, "Spotify has encountered some issues with connecting to the service. Please try again later.");
            Assert.AreEqual(null, app.GetMainGrammar());
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            MusicApp musicApp = db.MusicApps.Find(id);

            db.MusicApps.Remove(musicApp);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
 public ActionResult Edit([Bind(Include = "Id,Genre,ArtistName,AlbumName,Song,Year,NumberOfSongs")] MusicApp musicApp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(musicApp).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(musicApp));
 }
예제 #4
0
        public ActionResult Create([Bind(Include = "Id,Genre,ArtistName,AlbumName,Song,Year,NumberOfSongs")] MusicApp musicApp)
        {
            if (ModelState.IsValid)
            {
                db.MusicApps.Add(musicApp);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(musicApp));
        }
예제 #5
0
        // GET: MusicApps/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MusicApp musicApp = db.MusicApps.Find(id);

            if (musicApp == null)
            {
                return(HttpNotFound());
            }
            return(View(musicApp));
        }
예제 #6
0
        public void TestAppInvalidWhenNoPlaylistsAvailable()
        {
            IConfigurationManager   configManager = GetConfigurationManager();
            Mock <IMusicController> mc            = new Mock <IMusicController>(MockBehavior.Strict);

            AddComponentToConfigurationManager(mc.Object);

            mc.Setup(s => s.GetPlaylists()).Returns(new List <String>());
            MusicApp app = new MusicApp();

            TestInvalidApp(app, "Spotify has encountered some issues with connecting to the service. Please try again later.");

            mc.Verify(s => s.GetPlaylists(), Times.Exactly(2));
        }
예제 #7
0
        public void TestStopPlaylist()
        {
            Dictionary <String, String> expectedParams = new Dictionary <string, string>
            {
                { "Command", "music" },
                { "Subcommand", "stop" },
            };

            SetupMusicController();

            IConfigurationManager configManager = GetConfigurationManager();
            MusicApp app = new MusicApp();

            TestGrammar <MusicApp>("Stop the music", expectedParams);

            CleanupMusicControllers(1);
        }
예제 #8
0
        public void TestDeleteSong()
        {
            Dictionary <String, String> expectedParams = new Dictionary <string, string>
            {
                { "Command", "music" },
                { "Subcommand", "deletesong" },
            };

            SetupMusicController();

            IConfigurationManager configManager = GetConfigurationManager();
            MusicApp app = new MusicApp();

            TestGrammar <MusicApp>("Delete this song", expectedParams);

            CleanupMusicControllers(1);
        }
예제 #9
0
        public void TestListPlaylists()
        {
            Dictionary <String, String> expectedParams = new Dictionary <string, string>
            {
                { "Command", "music" },
                { "Subcommand", "playlists" },
            };

            SetupMusicController();

            IConfigurationManager configManager = GetConfigurationManager();
            MusicApp app = new MusicApp();

            TestGrammar <MusicApp>("What playlists are available", expectedParams);

            CleanupMusicControllers(1);
        }
예제 #10
0
        public void TestPlaySomePlaylist()
        {
            Dictionary <String, String> expectedParams = new Dictionary <string, string>
            {
                { "Command", "music" },
                { "Subcommand", "playrandom" },
                { "Playlist", "test playlist one" },
            };

            SetupMusicController();

            IConfigurationManager configManager = GetConfigurationManager();
            MusicApp app = new MusicApp();

            TestGrammar <MusicApp>("Play some test playlist one", expectedParams);

            CleanupMusicControllers(1);
        }
예제 #11
0
        public void TestWhoIsPlaying()
        {
            Dictionary <String, String> expectedParams = new Dictionary <string, string>
            {
                { "Command", "music" },
                { "Subcommand", "artist" },
            };

            SetupMusicController();

            IConfigurationManager configManager = GetConfigurationManager();
            MusicApp app = new MusicApp();

            TestGrammar <MusicApp>("Who is playing", expectedParams);
            TestGrammar <MusicApp>("Who is this", expectedParams);

            CleanupMusicControllers(2);
        }
예제 #12
0
 public MusicController(MusicApp musicApp, IWebHostEnvironment hostingEnvironment, IOptions <AppSetting> appConfiguration)
 {
     environment      = hostingEnvironment;
     MusicApp         = musicApp;
     AppConfiguration = appConfiguration;
 }