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)); }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }