コード例 #1
0
        public ActionResult SubmitDeleteCity(CitiesVM cvm)
        {
            DataLayer     dl     = new DataLayer();
            List <string> cities = (from u in dl.smartAgent
                                    where u.Location.ToUpper() == cvm.selectedCity.ToUpper()
                                    select u.Location).ToList <string>();

            cvm.cities = (from u in dl.smartAgent
                          select u.Location).ToList <string>();

            if (cities.Count == 1)
            {
                string cty = cities.FirstOrDefault().ToUpper();

                SmartAgent sa = (from u in dl.smartAgent
                                 where u.Location.ToUpper() == cty
                                 select u).ToList <SmartAgent>().FirstOrDefault();

                dl.smartAgent.Remove(sa);
                dl.SaveChanges();
                ViewData["msg"] = "City deleted!";
                return(View("DeleteCities", cvm));
            }
            ViewData["msg"] = "City does not exist!";
            return(View("DeleteCities", cvm));
        }
コード例 #2
0
        public ActionResult SubmitAddCty(SmartAgent sa)
        {
            DataLayer         dl     = new DataLayer();
            List <SmartAgent> cities = (from x in dl.smartAgent
                                        where x.Location.ToUpper() == sa.Location.ToUpper()
                                        select x).ToList <SmartAgent>();

            if (cities.Count != 0)
            {
                ViewData["msg"] = "City already exist!";
            }
            else if (sa.Location == null)
            {
                ViewData["msg"] = "Location required!";
            }

            else
            {
                dl.smartAgent.Add(sa);
                dl.SaveChanges();
                ViewData["msgsc"] = "City Added!";
            }

            return(View("AddCities", sa));
        }
コード例 #3
0
        public void CountAllQueenValidMoves_Assert27()
        {
            //arrange
            Piece[,] tempBoard = new Piece[8, 8];
            Queen myQueen = new Queen(true);

            tempBoard[3, 3] = myQueen;
            SmartAgent    tempAgent = new SmartAgent();
            PrivateObject obj       = new PrivateObject(tempAgent);

            //act
            List <PotentialMove> actions = (List <PotentialMove>)obj.Invoke("ListAllPossibleActions", tempBoard, true);

            //assert
            Assert.AreEqual(27, actions.Count);
        }
コード例 #4
0
        public void CountAllRookValidMoves_Assert14()
        {
            //arrange
            Piece[,] tempBoard = new Piece[8, 8];
            Rook myRook = new Rook(true);

            tempBoard[3, 3] = myRook;
            SmartAgent    tempAgent = new SmartAgent();
            PrivateObject obj       = new PrivateObject(tempAgent);

            //act
            List <PotentialMove> actions = (List <PotentialMove>)obj.Invoke("ListAllPossibleActions", tempBoard, true);

            //assert
            Assert.AreEqual(14, actions.Count);
        }
コード例 #5
0
        public void CountAllBishopValidMoves_Assert13()
        {
            //arrange
            Piece[,] tempBoard = new Piece[8, 8];
            Bishop myBishop = new Bishop(true);

            tempBoard[3, 3] = myBishop;
            SmartAgent    tempAgent = new SmartAgent();
            PrivateObject obj       = new PrivateObject(tempAgent);

            //act
            List <PotentialMove> actions = (List <PotentialMove>)obj.Invoke("ListAllPossibleActions", tempBoard, true);

            //assert
            Assert.AreEqual(13, actions.Count);
        }
コード例 #6
0
        public void CountAllKnightValidMoves_Assert8()
        {
            //arrange
            Piece[,] tempBoard = new Piece[8, 8];
            Knight myKnight = new Knight(true);

            tempBoard[3, 3] = myKnight;
            SmartAgent    tempAgent = new SmartAgent();
            PrivateObject obj       = new PrivateObject(tempAgent);

            //act
            List <PotentialMove> actions = (List <PotentialMove>)obj.Invoke("ListAllPossibleActions", tempBoard, true);

            //assert
            Assert.AreEqual(8, actions.Count);
        }
コード例 #7
0
        public void CountUtility_Assert20()
        {
            //arrange
            Piece[,] tempBoard = new Piece[8, 8];
            King myKing = new King(true);

            tempBoard[3, 3] = myKing;

            SmartAgent    tempAgent = new SmartAgent();
            PrivateObject obj       = new PrivateObject(tempAgent);

            //act
            int utility = (int)obj.Invoke("CountUtility", tempBoard);

            //assert
            Assert.AreEqual(20, utility);
        }
コード例 #8
0
        public void testKingValidMovesList_Assert8ValidMoves()
        {
            //arrange
            Piece[,] tempBoard = new Piece[8, 8];
            King myKing = new King(true);

            tempBoard[3, 3] = myKing;

            SmartAgent    tempAgent = new SmartAgent();
            PrivateObject obj       = new PrivateObject(tempAgent);

            //act
            List <PotentialMove> actions = (List <PotentialMove>)obj.Invoke("ListAllPossibleActions", tempBoard, true);

            //assert

            Assert.AreEqual(8, actions.Count);
        }
コード例 #9
0
        public void ListBlackPawnValidMovesAtFirstMove_Assert3()
        {
            //arrange
            Piece[,] tempBoard = new Piece[8, 8];
            Pawn myBlackPawn = new Pawn(false);
            Pawn myWhitePawn = new Pawn(true);

            tempBoard[2, 6] = myBlackPawn;
            tempBoard[1, 5] = myWhitePawn;
            SmartAgent    tempAgent = new SmartAgent();
            PrivateObject obj       = new PrivateObject(tempAgent);

            //act
            List <PotentialMove> actions = (List <PotentialMove>)obj.Invoke("ListAllPossibleActions", tempBoard, false);

            //assert

            Assert.AreEqual(3, actions.Count);
        }