예제 #1
0
        public void AdicionarMapeamento_Sobreescrever()
        {
            var factory = new GtFactory();

            factory.AddMapping <IPais, PaisStub>();
            factory.AddMapping <IPais, PaisStub2>();

            IPais pais = factory.Instantiate <IPais>();

            this.GarantirTipoDoObjeto <PaisStub2>(pais);
        }
예제 #2
0
        public void LimparTodosMapeamentos()
        {
            var factory = new GtFactory();

            factory.AddMapping <IPais, PaisStub>();
            factory.AddMapping <ICidade, CidadeStub>();

            factory.ClearAllMappings();

            IPais   pais   = factory.Instantiate <IPais>();
            ICidade cidade = factory.Instantiate <ICidade>();

            this.GarantirTipoDoObjeto <Pais>(pais);
            this.GarantirTipoDoObjeto <Cidade>(cidade);
        }
예제 #3
0
        public void EscapeFinishGameRound()
        {
            var player1 = new GtUserActionsListener();

            var factory = new GtFactory();

            factory.AddMapping <IAudioListener, DoubleAudioListenerDoNothing>();

            var controller = new GtGameRoundController(
                factory,
                new GtGameController(new GtFileLoaderDouble6()));

            controller.Update(player1);

            controller.GameRoundState = EnumGameRoundState.Playing;

            KeyboardState keyboardState = new KeyboardState(Keys.Escape);;
            GamePadState  gamePadState  = new GamePadState();

            player1.Update(keyboardState, gamePadState);

            controller.Update(player1);

            Assert.AreEqual(EnumGameRoundState.Finished, controller.GameRoundState);
        }
예제 #4
0
        public void LimparMapeamento()
        {
            var factory = new GtFactory();

            factory.AddMapping <IPais, PaisStub>();
            factory.AddMapping <ICidade, CidadeStub>();

            // O Método LimparMapeamento remove o mapeamento do tipo especificado.
            factory.CleanMappings <IPais>();

            IPais   pais   = factory.Instantiate <IPais>();
            ICidade cidade = factory.Instantiate <ICidade>();

            this.GarantirTipoDoObjeto <Pais>(pais);
            this.GarantirTipoDoObjeto <CidadeStub>(cidade);
        }
예제 #5
0
        public void StartHitedIsNotReset()
        {
            var factory = new GtFactory();

            factory.AddMapping <IGtPlayedNotesAnalyserHelper, MockGtPlayedNotesAnalyserHelperAlwaysIsNotPlaying>();

            var analyser = factory.Instantiate <IGtPlayedNotesAnalyser>(factory, new DoubleAudioListenerDoNothing(40));

            var note = new GtSceneGuitarNote(new BeatTick(1, 0), new BeatTick(1, 240), 6, 0);

            var startingNotes = new List <GtSceneGuitarNote>();

            startingNotes.Add(note);

            var expectedPlayingNotes = new List <GtSceneGuitarNote>();

            expectedPlayingNotes.Add(note);

            note.Playing    = true;
            note.StartHited = true;

            analyser.Analyse(startingNotes, expectedPlayingNotes);

            Assert.IsTrue(startingNotes[0].StartHited);
            Assert.IsFalse(startingNotes[0].Playing);
        }
예제 #6
0
        public void Constructor_OnePlayer()
        {
            var factory = new GtFactory();

            factory.AddMapping <IAudioListener, DoubleAudioListenerDoNothing>();

            var controller = new GtGameRoundController(
                factory,
                new GtGameController(new GtFileLoaderDouble6()));

            Assert.IsNotNull(controller);
        }
예제 #7
0
        public void SetupSong_ZeroPlayers()
        {
            var factory = new GtFactory();

            factory.AddMapping <IAudioListener, DoubleAudioListenerDoNothing>();

            var controller = new GtGameRoundController(
                factory,
                new GtGameController(new GtFileLoaderDouble6()));

            controller.SetupSong(0, new Double_SongPlayerWithTimer(new BeatTick(5, 0)), "Artist", "Album", "Song", 0.0f);
        }
예제 #8
0
        public void SetupSong_InvalidNumberOfPlayers()
        {
            var factory = new GtFactory();

            factory.AddMapping <IAudioListener, DoubleAudioListenerDoNothing>();

            var controller = new GtGameRoundController(
                factory,
                new GtGameController(new GtFileLoaderDouble6()));

            var guitar1 = new GtSceneGuitar(new GtTickDataTable(4));
            var guitar2 = new GtSceneGuitar(new GtTickDataTable(4));

            controller.SetupSong(1, new Double_SongPlayerWithTimer(new BeatTick(5, 0)), "Artist", "Album", "Song", 0.0f, guitar1, guitar2);
        }
예제 #9
0
        public void SetupSong_OnePlayer()
        {
            var factory = new GtFactory();

            factory.AddMapping <IAudioListener, DoubleAudioListenerDoNothing>();

            var controller = new GtGameRoundController(
                factory,
                new GtGameController(new GtFileLoaderDouble6()));

            var guitar1 = new GtSceneGuitar(new GtTickDataTable(4));

            controller.SetupSong(1, new Double_SongPlayerWithTimer(new BeatTick(5, 0)), "Artist", "Album", "Song", 0.0f, guitar1);

            Assert.AreEqual(1, controller.SceneGuitars.Count());
            Assert.AreSame(guitar1, controller.SceneGuitars[0]);
        }
예제 #10
0
        public void PlayMusic()
        {
            var factory = new GtFactory();

            factory.AddMapping <IAudioListener, DoubleAudioListenerDoNothing>();

            var controller = new GtGameRoundController(
                factory,
                new GtGameController(new GtFileLoaderDouble6()));

            var guitar1 = new GtSceneGuitar(new GtTickDataTable(4));

            controller.SetupSong(1, new Double_SongPlayerWithTimer(new BeatTick(5, 0)), "Artist", "Album", "Song", 0.0f, guitar1);

            controller.PlaySong();

            Assert.AreEqual(EnumGameRoundState.Playing, controller.GameRoundState);
        }
예제 #11
0
        public void OnePlayingNoteShouldReturn1Point()
        {
            var factory = new GtFactory();

            factory.AddMapping <IGtPlayedNotesAnalyserHelper, MockGtPlayedNotesAnalyserHelperAlwaysIsPlaying>();

            var analyser = factory.Instantiate <IGtPlayedNotesAnalyser>(factory, new DoubleAudioListenerDoNothing(40));

            var note1 = new GtSceneGuitarNote(new BeatTick(1, 0), new BeatTick(1, 240), 6, 0);

            var startingNotes = new List <GtSceneGuitarNote>();

            var expectedPlayingNotes = new List <GtSceneGuitarNote>();

            expectedPlayingNotes.Add(note1);

            var points = analyser.Analyse(startingNotes, expectedPlayingNotes);

            Assert.AreEqual(1, points);
        }
예제 #12
0
        public void RightArrowDecreaseVelocityByPointOne(decimal initialVelocityValue, decimal finalVelocityValue)
        {
            var player1 = new GtUserActionsListener();

            var factory = new GtFactory();

            factory.AddMapping <IAudioListener, DoubleAudioListenerDoNothing>();

            var controller = new GtGameRoundController(
                factory,
                new GtGameController(new GtFileLoaderDouble6()));

            KeyboardState keyboardState = new KeyboardState(Keys.Right);;
            GamePadState  gamePadState  = new GamePadState();

            player1.Update(keyboardState, gamePadState);

            controller.VelocityValue = initialVelocityValue;
            controller.Update(player1);

            Assert.AreEqual(finalVelocityValue, controller.VelocityValue);
        }
예제 #13
0
        public void AnalyseMustReturnZeroIfNoNoteIsCorrect()
        {
            var factory = new GtFactory();

            factory.AddMapping <IGtPlayedNotesAnalyserHelper, MockGtPlayedNotesAnalyserHelperAlwaysIsNotPlaying>();

            var analyser = factory.Instantiate <IGtPlayedNotesAnalyser>(factory, new DoubleAudioListenerDoNothing(40));

            var note = new GtSceneGuitarNote(new BeatTick(1, 0), new BeatTick(1, 240), 6, 0);

            var startingNotes = new List <GtSceneGuitarNote>();

            startingNotes.Add(note);

            var expectedPlayingNotes = new List <GtSceneGuitarNote>();

            expectedPlayingNotes.Add(note);

            var points    = analyser.Analyse(startingNotes, expectedPlayingNotes);
            var maxPoints = analyser.AnalyseMaximum(startingNotes, expectedPlayingNotes);

            Assert.AreEqual(0, points);
            Assert.AreEqual(101, maxPoints);
        }
예제 #14
0
        public void AdicionarMapeamento_InterfaceParaInterface()
        {
            var factory = new GtFactory();

            factory.AddMapping <IPais, IPaisStub>();
        }
예제 #15
0
        public void AdicionarMapeamento_ClasseParaClasse()
        {
            var factory = new GtFactory();

            factory.AddMapping <Pais, PaisStub2>();
        }