public void CheckFeedProducesCorrectAmount() { /*Angel Fish = 0.2, Babel Fish = 0.3 * Expected output = 5*/ Tank tank = new Tank(); List <Fish> fishesToAdd = new List <Fish>() { new Fish { FishName = "Fish One", FishType = FishTypes.AngelFish }, new Fish { FishName = "Fish Two", FishType = FishTypes.BabelFish } }; foreach (Fish fish in fishesToAdd) { tank.AddFishToTank(fish); } double expected = 0.5; double actual = tank.Feed(); Assert.AreEqual(expected, actual, "Incorrect Amount Of Food Displayed"); }
public void Babelfish_In_Tank_Needs_Point_Three_Food() { Tank FishTank = new Tank(); FishTank.AddFishToTank(new Babelfish()); string ExpectedValueOfFeed = "0.3"; string ActualValueOfFeed = FishTank.Feed(); Assert.AreEqual(ExpectedValueOfFeed, ActualValueOfFeed); }
public void Two_Babelfish_Three_Angelfish_Ten_Goldfish_In_Tank_Needs_Two_Point_Two_Food() { Tank FishTank = new Tank(); for (int b = 0; b < 2; b++) { FishTank.AddFishToTank(new Babelfish()); } for (int b = 0; b < 3; b++) { FishTank.AddFishToTank(new Angelfish()); } for (int b = 0; b < 10; b++) { FishTank.AddFishToTank(new Goldfish()); } string ExpectedValueOfFeed = "2.2"; string ActualValueOfFeed = FishTank.Feed(); Assert.AreEqual(ExpectedValueOfFeed, ActualValueOfFeed); }
public ActionResult AddFish(string name, string type) { Fish NewFish; try { switch (type) { case "Goldfish": NewFish = new Goldfish() { Name = name }; break; case "Angelfish": NewFish = new Angelfish() { Name = name }; break; case "Babelfish": NewFish = new Babelfish() { Name = name }; break; default: throw new Exception("Invalid Type OF Fish"); } FishTank.AddFishToTank(NewFish); } catch (Exception ex) { //Log Invalid fish type //Return to user there has been an errror } return(View("Index", FishTank)); }
public void CheckFishAddedToTank() { //Populated from UI string fishName = "Fishy McFishman"; FishTypes fishType = FishTypes.GoldFish; Fish fishToAdd = new Fish { FishName = fishName, FishType = fishType }; Tank tank = new Tank(); tank.AddFishToTank(fishToAdd); List <Fish> fishInTheTank = tank.fishInTank; Assert.IsNotNull(fishInTheTank, $"There are {fishInTheTank.Count} fish in the tank."); }
public void CheckFoodRequiredPopulates() { //Populated from UI string fishName = "Fishy McFishman"; FishTypes fishType = FishTypes.GoldFish; Fish fishToAdd = new Fish { FishName = fishName, FishType = fishType }; Tank tank = new Tank(); tank.AddFishToTank(fishToAdd); double expected = 0.1; double actual = tank.fishInTank[0].FoodRequired; Assert.AreEqual(expected, actual, 0.001, "Fish Food not Correctly Setup"); }