public ActionResult Index(Island island) { var islandFactory = new IslandFactory(); // var aa = db.Player.ToList(); //ModelState.Clear();// This clears the models on the view // ModelState.AddModelError("MoveOne", "MoveOne No validation for this"); //ModelState.AddModelError("MoveTwo", "MoveTwo No validation for this"); //ModelState.AddModelError("MoveThree", "MoveThree No validation for this"); if (island.MoveOne == Guid.Empty) { ModelState.AddModelError("MoveOne", "MoveOne not selected"); } if (island.MoveTwo == Guid.Empty) { ModelState.AddModelError("MoveTwo", "MoveTwo not selected"); } if (island.MoveThree == Guid.Empty) { ModelState.AddModelError("MoveThree", "MoveThree not selected"); } if (ModelState.IsValid) { // var startingTile = db.IslandTile.Where(x => x. == island.CurrentPlayerId).Single(); var firstMoveTile = db.IslandTile.Where(x => x.Id == island.MoveOne).Single(); var secondMoveTile = db.IslandTile.Where(x => x.Id == island.MoveTwo).Single(); var thirdMoveTile = db.IslandTile.Where(x => x.Id == island.MoveThree).Single(); ModelState.Clear(); var ioc = new IOC(); var canMoveValidationList = ioc.GetList <ICanMoveValidation>().ToList(); ValidationResults validationResults; foreach (var canMoveValidation in canMoveValidationList) { validationResults = canMoveValidation.IsValid(firstMoveTile, secondMoveTile, new Player()); if (!validationResults.IsValid) { ModelState.AddModelError("", validationResults.ErrorMessage); } } } var islandTileList = db.IslandTile.ToList(); Island newIsland = islandFactory.Create(islandTileList); return(View(newIsland)); }
public void TestMethod2() { //Arange var ioc = new IOC(); ioc.Register<ICalculateTax>("CompanyATax"); //Act var calculateTax = ioc.GetList<ICalculateTax>("CompanyATax").ToList(); //Asert Assert.IsInstanceOfType(calculateTax.First(), typeof(CompanyATax)); }