public void CanAssignFirstTaskTipTest() { var team = new Team() .CreateTeamGameState(game) .AssignTask(task1, new DateTime(2010, 1, 1, 21, 0, 0)); Expect.Call(repository.Get(1)) .Return(game); Expect.Call(() => gameService.AssignNewTaskTip(team.TeamGameState.ActiveTaskState, task1Tip0)) .Do((Action<TeamTaskState, Tip>)((ts, tip) => team.TeamGameState.ActiveTaskState.AcceptedTips.Add(new AcceptedTip { Tip = tip, TeamTaskState = ts })) ); mocks.ReplayAll(); service.RecalcGameState(new DateTime(2010, 1, 1, 21, 0, 0)); mocks.VerifyAll(); Assert.AreEqual(1, team.TeamGameState.ActiveTaskState.AcceptedTips.Count()); }
public void CanEnsureTeamCreationIsValid() { Team teamFromForm = new Team(); ViewResult result = controller.Create(teamFromForm).AssertViewRendered(); result.ViewData.Model.ShouldNotBeNull(); result.ViewData.Model.ShouldBeOfType(typeof(TeamsController.TeamFormViewModel)); }
public void CanCompareTeams() { Team instance = new Team(); instance.Name = "Beavers"; Team instanceToCompareTo = new Team(); instanceToCompareTo.Name = "Beavers"; instance.ShouldEqual(instanceToCompareTo); }
public void CanCloseGameTest() { Game game = new Game { GameState = GameStates.Finished }; var team = new Team() .CreateTeamGameState(game); mocks.ReplayAll(); service.CloseGame(game); mocks.VerifyAll(); Assert.AreEqual(GameStates.Cloused, game.GameState); Assert.IsNull(team.TeamGameState); Assert.IsNull(team.Game); }
public void CanCloseGameTest() { Expect.Call(teamGameStateRepository.DbContext).Return(dbContext); Game game = new Game { GameState = GameStates.Finished }; var team = new Team() .CreateTeamGameState(game); mocks.ReplayAll(); service.CloseGame(game); mocks.VerifyAll(); Assert.AreEqual(GameStates.Cloused, game.GameState); Assert.IsNull(team.TeamGameState); Assert.IsNull(team.Game); }
public void CanStartupTest() { Expect.Call(gameRepository.GetAll()).Return(new List<Game> { new Game() }); Expect.Call(teamGameStateRepository.DbContext).Return(dbContext); mocks.ReplayAll(); Game game = new Game(); var team = new Team { Game = game }; team.Users.Add(new User { Team = team }); game.Teams.Add(team); service.StartupGame(game); mocks.VerifyAll(); Assert.AreEqual(GameStates.Startup, game.GameState); Assert.IsNotNull(team.TeamGameState); Assert.AreEqual(1, team.TeamGameStates.Count); }
public void SouldNotAssignTip4RussianRouletteTaskTest() { var russianRouletteTask = new Task { TaskType = TaskTypes.RussianRoulette }; russianRouletteTask.Tips.Add(new Tip { SuspendTime = 0, Task = russianRouletteTask }); russianRouletteTask.Tips.Add(new Tip { SuspendTime = 30, Task = russianRouletteTask }); russianRouletteTask.Tips.Add(new Tip { SuspendTime = 60, Task = russianRouletteTask }); var team = new Team() .CreateTeamGameState(game) .AssignTask(russianRouletteTask, new DateTime(2010, 1, 1, 21, 0, 0)); Expect.Call(repository.Get(1)) .Return(game); DoNotExpect.Call(() => gameService.AssignNewTaskTip(null, null)); mocks.ReplayAll(); service.RecalcGameState(new DateTime(2010, 1, 1, 21, 0, 0)); mocks.VerifyAll(); Assert.AreEqual(0, team.TeamGameState.ActiveTaskState.AcceptedTips.Count()); }
public void ShouldNotOvertimeTest() { var team = new Team() .CreateTeamGameState(game) .AssignTask(task1, new DateTime(2010, 1, 1, 21, 0, 0)) .AssignTip(task1Tip0); Expect.Call(repository.Get(1)).Return(game); DoNotExpect.Call(() => gameService.CloseTaskForTeam( team.TeamGameState.ActiveTaskState, TeamTaskStateFlag.Overtime)); DoNotExpect.Call(() => gameService.AssignNewTask(team.TeamGameState, task1)); mocks.ReplayAll(); service.RecalcGameState(new DateTime(2010, 1, 1, 22, 29, 59)); mocks.VerifyAll(); }
public void ShouldNotOvertime4NeedForSpeedTaskTest() { var needForSpeedTask = new Task { TaskType = TaskTypes.NeedForSpeed }; needForSpeedTask.Tips.Add(new Tip { SuspendTime = 60 + 10, Task = needForSpeedTask }); needForSpeedTask.Codes.Add(new Code { Name = "1", Task = needForSpeedTask }); var team = new Team() .CreateTeamGameState(game) .AssignTask(needForSpeedTask, new DateTime(2010, 1, 1, 21, 0, 0)); team.TeamGameState.ActiveTaskState.AccelerationTaskStartTime = new DateTime(2010, 1, 1, 22, 00, 0); Expect.Call(repository.Get(1)).Return(game); DoNotExpect.Call(() => gameService.CloseTaskForTeam( team.TeamGameState.ActiveTaskState, TeamTaskStateFlag.Overtime)); DoNotExpect.Call(() => gameService.AssignNewTask(team.TeamGameState, task1)); mocks.ReplayAll(); service.RecalcGameState(new DateTime(2010, 1, 1, 22, 15, 0)); mocks.VerifyAll(); }
public void ShouldNotAssignFirstTaskTest() { var team = new Team(); var tgs = new TeamGameState { Game = game, Team = team }; team.TeamGameState = tgs; game.Teams.Add(team); Expect.Call(repository.Get(1)) .Return(game).Repeat.Any(); DoNotExpect.Call(() => gameService.AssignNewTask(tgs, null)); mocks.ReplayAll(); service.RecalcGameState(new DateTime(2010, 1, 1, 20, 59, 59)); mocks.VerifyAll(); }
public void CheckSuccessCompleteTest() { var team = new Team() .CreateTeamGameState(game) .AssignTask(task1, new DateTime(2010, 1, 1, 21, 0, 0)) .AssignTip(task1Tip0) .AcceptCode(task1.Codes[0], new DateTime(2010, 1, 1, 21, 10, 0)); Expect.Call(repository.Get(1)).Return(game); Expect.Call(() => gameService.CloseTaskForTeam( team.TeamGameState.ActiveTaskState, TeamTaskStateFlag.Success)); Expect.Call(() => gameService.AssignNewTask(team.TeamGameState, task1)); mocks.ReplayAll(); service.RecalcGameState(new DateTime(2010, 1, 1, 22, 30, 0)); mocks.VerifyAll(); }
public void CanCheckExceededBadCodesTest() { var team = new Team() .CreateTeamGameState(game) .AssignTask(task1, new DateTime(2010, 1, 1, 21, 0, 0)) .AssignTip(task1Tip0); Expect.Call(repository.Get(1)) .Return(game); Expect.Call(() => gameService.CheckExceededBadCodes(team.TeamGameState)); mocks.ReplayAll(); service.RecalcGameState(new DateTime(2010, 1, 1, 21, 30, 0)); mocks.VerifyAll(); }
public EncounterViewData WithTeam(Team team) { Team = team; return this; }
private void TransferFormValuesTo(Team teamToUpdate, Team teamFromForm) { teamToUpdate.Name = teamFromForm.Name; teamToUpdate.AccessKey = teamFromForm.AccessKey; teamToUpdate.FinalTask = teamFromForm.FinalTask; }
public void Setup() { mocks = new MockRepository(); taskRepository = mocks.DynamicMock<IRepository<Task>>(); teamTaskStateRepository = mocks.DynamicMock<IRepository<TeamTaskState>>(); acceptedCodeRepository = mocks.DynamicMock<IRepository<AcceptedCode>>(); acceptedBadCodeRepository = mocks.DynamicMock<IRepository<AcceptedBadCode>>(); acceptedTipRepository = mocks.DynamicMock<IRepository<AcceptedTip>>(); dispatcherFactory = mocks.DynamicMock<ITaskDispatcherFactory>(); taskDispatcher = mocks.DynamicMock<ITaskDispatcher>(); game = new Game { Name = "Game" }; team = new Team { Name = "Team" }; }
public void CanStopGameTest() { IGameDemon gameDemon = mocks.DynamicMock<IGameDemon>(); GameService gameService = new GameService(gameRepository, teamRepository, teamGameStateRepository, taskService, gameDemon); Game game = new Game { GameState = GameStates.Started }; Team team = new Team() .CreateTeamGameState(game) .AssignTask(task1, new DateTime(2010, 1, 1, 21, 0, 0)); Expect.Call(gameDemon.Stop); Expect.Call(gameRepository.SaveOrUpdate(game)); Expect.Call( () => taskService.CloseTaskForTeam( team.TeamGameState.ActiveTaskState, TeamTaskStateFlag.Overtime)); Expect.Call(teamRepository.SaveOrUpdate(team)); Expect.Call(teamGameStateRepository.SaveOrUpdate(team.TeamGameState)); Expect.Call(teamGameStateRepository.DbContext).Return(dbContext); mocks.ReplayAll(); gameService.StopGame(game); mocks.VerifyAll(); Assert.AreEqual(GameStates.Finished, game.GameState); }
public void ShouldNotAssignFirstTaskTest4() { var team = new Team(); var tts = new TeamTaskState { Task = task1 }; var tgs = new TeamGameState { Game = game, Team = team, ActiveTaskState = tts }; tgs.AcceptedTasks.Add(tts); team.TeamGameState = tgs; game.Teams.Add(team); Expect.Call(repository.Get(1)) .Return(game).Repeat.Any(); DoNotExpect.Call(() => gameService.AssignNewTask(tgs, null)); mocks.ReplayAll(); service.RecalcGameState(new DateTime(2010, 1, 1, 22, 0, 0)); mocks.VerifyAll(); }
/// <summary> /// Creates a valid, transient Team; typical of something retrieved back from a form submission /// </summary> private Team CreateTransientTeam() { Team team = new Team() { Name = "Beavers" }; return team; }