Esempio n. 1
0
        public void SetMode_ShouldSetModeToPause()
        {
            var context = new Mocks().GetDefaultDatabaseContext();

            var fightEntity = new Fight
            {
                Id            = 1,
                BlueAthleteId = "abcd",
                RedAthleteId  = "efgh",
                Structure     = new FightStructure()
                {
                    Round = new Round()
                    {
                        BreakDuration = 1000,
                        Duration      = 3000,
                        RoundsCount   = 3
                    }
                }
            };

            context.Fights.Add(fightEntity);
            context.SaveChanges();

            var state = new FightState(context);

            state.Initialize(1);

            state.SetMode("pause");
            Assert.Equal(state.RemainingTime, 1000);
        }
Esempio n. 2
0
        public void EndRound_ShouldEndRound()
        {
            var context = new Mocks().GetDefaultDatabaseContext();

            var fightEntity = new Fight
            {
                Id            = 1,
                BlueAthleteId = "abcd",
                RedAthleteId  = "efgh",
                Structure     = new FightStructure()
                {
                    Round = new Round()
                    {
                        BreakDuration = 1000,
                        Duration      = 3000,
                        RoundsCount   = 3
                    }
                }
            };

            context.Fights.Add(fightEntity);
            context.SaveChanges();

            var fightContext = new FightContext(context);

            fightContext.InitState(1);
            fightContext.EndRound();
            Thread.SpinWait(1000);

            var state = fightContext.GetFightState();

            Assert.Equal(state.Id, 1);
            Assert.Equal(state.Paused, false);
            Assert.Equal(state.Started, false);
            Assert.True(state.RemainingTime < 1000);
            Assert.Equal(state.Round, 1);
            Assert.Equal(state.RedFighter.Id, "efgh");
            Assert.Equal(state.BlueFighter.Id, "abcd");
        }