Пример #1
0
        public void previewSongTest() //Unit Test by Rafael (Testing to see if the correct audio source is playing when previewing a song)
        {
            Canvas songSelectionCanvas = Resources.Load <Canvas>("Prefabs/SongSelectionCanvas");

            songSelectionCanvas = Canvas.Instantiate(Resources.Load <Canvas>("Prefabs/SongSelectionCanvas"));

            SongSelectionScript songSelectionScript = songSelectionCanvas.GetComponent <SongSelectionScript>();

            songSelectionScript.FindSongs();

            GameObject[] songPanels = songSelectionScript.GetSongs();

            int numOfPanels = songSelectionScript.GetNumOfSongs();;       //get the number of songPanels in the canvas
            int randPanel   = Random.Range(0, numOfPanels - 1);           //get a random song panel
            int activePanel = songSelectionScript.GetActiveSongCounter(); //get the active song panel

            songPanels[activePanel].SetActive(false);                     //hide the current active song panel

            songSelectionScript.SetActiveSongCounter(randPanel);
            activePanel = randPanel;

            songPanels[activePanel].SetActive(true);

            AudioSource audioSource = songPanels[activePanel].GetComponentInChildren <AudioSource>();

            songSelectionScript.onClickPreviewSong();

            Assert.IsTrue(audioSource.isPlaying);
        }
Пример #2
0
        public void muteGameTest()
        {
            Canvas songSelectionCanvas = Resources.Load <Canvas>("Prefabs/SongSelectionCanvas");

            songSelectionCanvas = Canvas.Instantiate(Resources.Load <Canvas>("Prefabs/SongSelectionCanvas"));

            SongSelectionScript songSelectionScript = songSelectionCanvas.GetComponent <SongSelectionScript>();

            songSelectionScript.FindSongs();

            AudioSource buttonClickSound = songSelectionScript.buttonClickSound;

            songSelectionScript.OnClickMute();
            AudioSource currentSongAudioSource = songSelectionScript.GetCurrentSong().GetComponent <AudioSource>();

            Assert.IsTrue(buttonClickSound.mute);
            Assert.IsTrue(currentSongAudioSource.mute);

            songSelectionScript.OnClickMute();

            Assert.IsFalse(buttonClickSound.mute);
            Assert.IsFalse(currentSongAudioSource.mute);
        }