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 ActionResult CalculateSimpleInterestResult()
        {
            var islandFactory = new IslandFactory();


            var island = islandFactory.Create();

            return(View(island));
        }
        public void CreateReturnsIsland_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            Assert.IsInstanceOfType(island, typeof(Island));
        }
        public void CreateReturnsIslandWithListOfIslandTiles_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            Assert.IsInstanceOfType(island.IslandBoard, typeof(List <IslandTile>));
        }
        public void PlayerCountIsSix_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island       = islandFactory.Create();
            var playersTiles = island.IslandBoard.Where(x => x.PlayersOnTile.Count != 0).Count();

            //Assert
            Assert.AreNotEqual(playersTiles, 6);
        }
        public ActionResult Index()
        {
            var islandTileList = db.IslandTile.ToList();

            var playerList = db.Player.ToList();


            var    islandFactory = new IslandFactory();
            Island island        = islandFactory.Create(islandTileList);

            return(View(island));
        }
        public void TileIsAtSixFour_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            Assert.AreEqual(island.IslandBoard[23].RowNumber, 6);
            Assert.AreEqual(island.IslandBoard[23].ColumnNumber, 4);
        }
        public void TileIsAtFiveThree_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            Assert.AreEqual(island.IslandBoard[19].RowNumber, 5);
            Assert.AreEqual(island.IslandBoard[19].ColumnNumber, 3);
        }
        public void CreateReturnsIslandWithListOfIslandTiles_StartingPlayerCountSix_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTileCount = island.IslandBoard.Where(x => x.StartingTileForPlayer != PlayerColour.None.ToString()).Count();

            Assert.AreEqual(islandTileCount, 6);
        }
        public void CreateReturnsIslandWithListOfIslandTiles_TilesCountThirtySix_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTileCount = island.IslandBoard.Count();

            Assert.AreEqual(islandTileCount, 36);
        }
        public void CreateReturnsIslandWithListOfIslandTiles_CopperGateStartingPostionsForGreen_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Copper Gate");

            Assert.AreEqual(islandTile.StartingTileForPlayer, PlayerColour.Green.ToString());
        }
        public void CreateReturnsIslandWithListOfIslandTiles_FoolsLandingHelicopterSite_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Fools' Landing");

            Assert.AreEqual(islandTile.HelicopterSite, true);
        }
        public void TileThatDontStatueCount20()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTileCount = island.IslandBoard.Count(x => x.CanHaveStatue == TreasureStatue.None.ToString());

            Assert.AreEqual(islandTileCount, 28);
        }
        public void CreateReturnsIslandWithListOfIslandTiles_SilverGatNotHelicopterSite_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Silver Gate");

            Assert.AreEqual(islandTile.HelicopterSite, false);
        }
        public void CreateReturnsIslandWithListOfIslandTiles_FirstItemIslandTile_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Phantom Rock");

            Assert.IsInstanceOfType(islandTile, typeof(IslandTile));
        }
        public void CreateReturnsIslandWithListOfIslandTiles_SecondItemNotNull_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Silver Gate");

            Assert.AreNotEqual(islandTile, null);
        }
        public void TileCaveOfShadowsCanHaveStatue()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Cave of Shadows");

            Assert.AreEqual(islandTile.CanHaveStatue, TreasureStatue.CrystalOfFire.ToString());
        }
        public void TileTidlePalaceCanHaveStatue()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Tidal Palace");

            Assert.AreEqual(islandTile.CanHaveStatue, TreasureStatue.OceansChalice.ToString());
        }
        public void TileTempleOfTheSunCanHaveStatue()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Temple of the Sun");

            Assert.AreEqual(islandTile.CanHaveStatue, TreasureStatue.EarthStone.ToString());
        }
        public void CreateReturnsIslandWithListOfIslandTiles_FoolsLandingStartingPostionsForBlue_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Fools' Landing");

            Assert.AreEqual(islandTile.StartingTileForPlayer, PlayerColour.Blue.ToString());
        }
        public void TileWhisperingGardenCanHaveStatue()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Whispering Garden");

            Assert.AreEqual(islandTile.CanHaveStatue, TreasureStatue.StatueOfTheWind.ToString());
        }
        public void CreateReturnsIslandWithListOfIslandTiles_PhantomRockNotStartingPostions_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Phantom Rock");

            Assert.AreEqual(islandTile.StartingTileForPlayer, PlayerColour.None.ToString());
        }
        public void IslandTilesThatAreMottSea_TilesCountTwentyFour_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTileCount = island.IslandBoard.Where(x => x.Name != "Sea").Count();

            Assert.AreEqual(islandTileCount, 24);
        }
        public void CreateReturnsIslandWithListOfIslandTiles_FirstItemIslandTileIsPhantomRock_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var islandTile = island.IslandBoard.SingleOrDefault(x => x.Name == "Phantom Rock");

            Assert.AreEqual(islandTile.Name, "Phantom Rock");
        }
        public void OneTileHasStatueOfTheWindStatue()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            var tiles         = island.IslandBoard.Where(x => x.CanHaveStatue == TreasureStatue.StatueOfTheWind.ToString());
            var hasTilesCount = tiles.Where(x => x.HasStatue).Count();

            Assert.AreEqual(hasTilesCount, 1);
        }
        public void PlayersOnTileNotNull_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            foreach (var asdf in island.IslandBoard)
            {
                Assert.AreNotEqual(asdf.PlayersOnTile, null);
            }
        }
        public void CreateReturnsIslandWithListOfIslandTiles_IdHasValue_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            //Assert
            foreach (var islandTile in island.IslandBoard)
            {
                Assert.AreNotEqual(islandTile.Id, Guid.Empty);
            }
        }
        public void TileHasOnePlayer_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island       = islandFactory.Create();
            var playersTiles = island.IslandBoard.Where(x => x.PlayersOnTile.Count != 0);

            //Assert
            foreach (var item in playersTiles)
            {
                Assert.AreEqual(item.PlayersOnTile.Count, 1);
            }
        }
        public void PlayerOnStartingTile_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island       = islandFactory.Create();
            var playersTiles = island.IslandBoard.Where(x => x.PlayersOnTile.Count != 0);

            //Assert
            foreach (var item in playersTiles)
            {
                Assert.AreEqual(item.StartingTileForPlayer, item.PlayersOnTile[0].Colour);
            }
        }
        public void NotInAlphabeticalOrder_IsValid()
        {
            //Arrange
            var islandFactory = new IslandFactory();

            //Act
            var island = islandFactory.Create();

            var zero = (island.IslandBoard[0].Name == "Breakers Bridge");
            var one  = (island.IslandBoard[1].Name == "Bronze Gate");
            var two  = (island.IslandBoard[2].Name == "Cave of Embers");

            //Assert
            Assert.IsFalse((zero && one && two));
        }