public void Initialize_PassedFightId_ShouldReturnFreshState() { var fightEntity = new Fight { Id = 1, BlueAthleteId = "abcd", RedAthleteId = "efgh" }; var context = GetDefaultDatabaseContext(); var fightState = new FightState(context); context.Fights.Add(fightEntity); context.SaveChanges(); fightState.Initialize(1); var expected = new FightState(context) { BlueFighter = new Fighter("abcd", new List <FightPoint>()), RedFighter = new Fighter("efgh", new List <FightPoint>()), Round = 0, Id = 1 }; Assert.Equal(expected, fightState); }
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); }
public void Initialize_PassedFightId_ShouldReturnPersistedState() { var fightEntity = new Fight { Id = 1, BlueAthleteId = "abcd", RedAthleteId = "efgh" }; var fightPoints = new List <FightPoint> { new FightPoint { FightId = 1, JudgeId = "qwerty", Points = 9, FighterId = "abcd", RoundId = 1 }, new FightPoint { FightId = 1, JudgeId = "qwerty", Points = 10, FighterId = "efgh", RoundId = 1 } }; var context = GetDefaultDatabaseContext(); var fightState = new FightState(context); context.Fights.Add(fightEntity); context.FightPoints.AddRange(fightPoints); context.SaveChanges(); fightState.Initialize(1); var expected = new FightState(context) { BlueFighter = new Fighter("abcd", fightPoints.Where(f => f.FighterId == "abcd").ToList()), RedFighter = new Fighter("efgh", fightPoints.Where(f => f.FighterId == "efgh").ToList()) }; Assert.Equal(expected, fightState); }
public void InitState(int id) { _fightState.Initialize(id); }