Ejemplo n.º 1
0
        public void Editing_Game_Object_Updated()
        {
            var g = new Game();
            gameRepository.Setup(r => r.Get(5)).Returns(g);

            var vm = new EditGameViewModel
                         {
                             Id = 5,
                             Description = "game",
                         };
            controller.Edit(vm);
            gameRepository.Verify(r => r.Save(g));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(EditGameViewModel gameViewModel)
        {
            gameViewModel.CurrentPlayer = currentPlayer;
            gameViewModel.CpuPlayer = playerRepository.GetCpuPlayer();
            Game g = gameRepository.Get(gameViewModel.Id);
            if (g == null)
                return RedirectToAction<ListController>(c => c.Games("All", null));

            g.Description = gameViewModel.Description;

            if (gameViewModel.CanEdit(g.SovietPlayer))
            {
                g.SovietPlayer = gameViewModel.GetSovietPlayer();
            }
            if (gameViewModel.CanEdit(g.GermanPlayer))
            {
                g.GermanPlayer = gameViewModel.GetGermanPlayer();
            }
            if (gameViewModel.CanEdit(g.BritishPlayer))
            {
                g.BritishPlayer= gameViewModel.GetBritishPlayer();
            }
            if (gameViewModel.CanEdit(g.JapanesePlayer))
            {
                g.JapanesePlayer = gameViewModel.GetJapanesePlayer();
            }
            if (gameViewModel.CanEdit(g.AmericanPlayer))
            {
                g.AmericanPlayer = gameViewModel.GetAmericanPlayer();
            }
            gameRepository.Save(g);
            return ToAllGamesList();
        }
Ejemplo n.º 3
0
        //
        // GET: /Game/Edit/5
        public ActionResult Edit(int id)
        {
            Game g = gameRepository.Get(id);
            if (g == null)
                return ToAllGamesList();

            var vm = new EditGameViewModel
                         {
                             Id = g.Id,
                             Description = g.Description,
                             CanStartGame = g.CanStart(currentPlayer),
                             OwnerDisplayName = Player.GetDisplayName(g.Owner, currentPlayer),
                             AmericanPlayerState = new EditGameViewModel.PlayerState(Nationality.UnitedStates, g.AmericanPlayer, currentPlayer),
                             SovietPlayerState = new EditGameViewModel.PlayerState(Nationality.SovietUnion, g.SovietPlayer, currentPlayer),
                             JapanesePlayerState = new EditGameViewModel.PlayerState(Nationality.Japan, g.JapanesePlayer, currentPlayer),
                             BritishPlayerState = new EditGameViewModel.PlayerState(Nationality.UnitedKingdom, g.BritishPlayer, currentPlayer),
                             GermanPlayerState = new EditGameViewModel.PlayerState(Nationality.Germany, g.GermanPlayer, currentPlayer),
                         };
            return View(vm);
        }
Ejemplo n.º 4
0
 private static void AssertPlayerState(EditGameViewModel.PlayerState state, Nationality nationality, bool isSelf, bool isCpu, bool isOpen)
 {
     Assert.That(state.Nationality, Is.EqualTo(nationality));
     Assert.AreEqual(state.IsSelf, isSelf);
     Assert.AreEqual(state.IsCpu, isCpu);
     Assert.AreEqual(state.IsOpen, isOpen);
 }