public override void DoAction(NWPlayer player, string pageName, int responseID) { DialogResponse response = GetResponseByID("MainPage", responseID); int jukeboxSongID = (int)response.CustomData; JukeboxSong song = DataService.JukeboxSong.GetByID(jukeboxSongID); player.FloatingText("Song Selected: " + song.DisplayName); _.MusicBackgroundChangeDay(player.Area, song.AmbientMusicID); _.MusicBackgroundChangeNight(player.Area, song.AmbientMusicID); _.MusicBackgroundPlay(player.Area); }
public void GetByID_OneItem_ReturnsJukeboxSong() { // Arrange JukeboxSong entity = new JukeboxSong { ID = 1 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <JukeboxSong>(entity)); // Assert Assert.AreNotSame(entity, _cache.GetByID(1)); }
public void GetByID_TwoItems_ReturnsCorrectObject() { // Arrange JukeboxSong entity1 = new JukeboxSong { ID = 1 }; JukeboxSong entity2 = new JukeboxSong { ID = 2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <JukeboxSong>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <JukeboxSong>(entity2)); // Assert Assert.AreNotSame(entity1, _cache.GetByID(1)); Assert.AreNotSame(entity2, _cache.GetByID(2)); }
public void GetByID_RemovedItem_ReturnsCorrectObject() { // Arrange JukeboxSong entity1 = new JukeboxSong { ID = 1 }; JukeboxSong entity2 = new JukeboxSong { ID = 2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <JukeboxSong>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <JukeboxSong>(entity2)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <JukeboxSong>(entity1)); // Assert Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(1); }); Assert.AreNotSame(entity2, _cache.GetByID(2)); }
public void GetByID_NoItems_ThrowsKeyNotFoundException() { // Arrange JukeboxSong entity1 = new JukeboxSong { ID = 1 }; JukeboxSong entity2 = new JukeboxSong { ID = 2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <JukeboxSong>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <JukeboxSong>(entity2)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <JukeboxSong>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <JukeboxSong>(entity2)); // Assert Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(1); }); Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(2); }); }