public void DB_CreatesNewEntries_Collection() { HeroController controller = new HeroController(db); Hero testHero = new Hero { Name = "Mario", Weapon = "Fire_Flower" }; controller.Create(testHero, null); var collection = (controller.Index() as ViewResult).ViewData.Model as List <Hero>; CollectionAssert.Contains(collection, testHero); }
public void DB_DeleteSpecificHero_Collection() { HeroController controller = new HeroController(db); Hero testHero1 = new Hero { Name = "Luigi", Weapon = "vacuum" }; Hero testHero2 = new Hero { Name = "Peach", Weapon = "Toad" }; controller.Create(testHero1, null); controller.Create(testHero2, null); var collection = (controller.Index() as ViewResult).ViewData.Model as List <Hero>; controller.DeleteConfirmed(collection[1].HeroId); var collection2 = (controller.Index() as ViewResult).ViewData.Model as List <Hero>; CollectionAssert.DoesNotContain(collection2, testHero1); }
public void Mock_PostViewResultCreate_ViewResult() { Hero testHero = new Hero { HeroId = 2, Name = "Mario", Weapon = "Fire_Flower" }; DbSetup(); HeroController controller = new HeroController(mock.Object); var resultView = controller.Create(testHero, null) as RedirectToActionResult; Assert.IsInstanceOfType(resultView, typeof(RedirectToActionResult)); }
public void DB_EditSpecificHero_Hero() { HeroController controller = new HeroController(db); Hero testHero1 = new Hero { Name = "Mario", Weapon = "Yoshi" }; controller.Create(testHero1, null); var collection = (controller.Index() as ViewResult).ViewData.Model as List <Hero>; Hero heroToEdit = (controller.Edit(collection[0].HeroId) as ViewResult).ViewData.Model as Hero; heroToEdit.Name = "New Mario"; controller.Edit(heroToEdit); var collection2 = (controller.Index() as ViewResult).ViewData.Model as List <Hero>; Assert.AreEqual("New Mario", collection2[0].Name); }
public static Player Create(PlayerParameters parameters) { GameObject playerObject = new GameObject("Player_" + parameters.HeroClass.Name()); playerObject.transform.localScale = Vector3.one * 50f; playerObject.transform.localEulerAngles = new Vector3(90f, 0f, 0f); playerObject.transform.position = parameters.PlayerPosition; Player player = playerObject.AddComponent <Player>(); player.Deck = parameters.Deck; foreach (BaseCard card in player.Deck) { card.Player = player; } player.ManaController = ManaController.Create(player, parameters.ManaPosition, parameters.DisplayCrystals); player.HandController = HandController.Create(player, parameters.HandPosition, parameters.HandInverted); player.BoardController = BoardController.Create(player, parameters.BoardPosition); player.Hero = new Hero() { Player = player, Class = parameters.HeroClass, BaseHealth = parameters.HeroHealth, BaseArmor = parameters.HeroArmor }; player.Hero.Initialize(); player.HeroController = HeroController.Create(player.Hero); player.Hero.HeroPower = (BaseHeroPower)Activator.CreateInstance(parameters.HeroPower, new object[] { player.Hero }); return(player); }