public void RemovePersonnelTest() { Ship ship = new Ship(ShipLayout.Small, PlayerColor.Blue); Cabin cabinWithEngineAlien = new Cabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); Part engineSupportUnit = new EngineCabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); Cabin cabinWithHumans1 = new Cabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); Cabin cabinWithHumans2 = new Cabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); Cabin cockpit = ship.GetCockpit() as Cabin; //crew is empty by default Assert.Equal(Personnel.None, cockpit.Personnel); Assert.Equal(Personnel.None, cabinWithEngineAlien.Personnel); Assert.Equal(Personnel.None, cabinWithHumans1.Personnel); Assert.Equal(Personnel.None, cabinWithHumans2.Personnel); Assert.Equal(0, ship.CrewCount); ship.AddPart(cabinWithEngineAlien, 5, 6); ship.AddPart(engineSupportUnit, 5, 7); ship.AddPart(cabinWithHumans1, 6, 5); ship.AddPart(cabinWithHumans2, 4, 5); ship.AddAlien(5, 6, Personnel.EngineAlien); ship.FillCabins(); //FillCabisn sets all cabins' personnel (where its not set already) to humandouble Assert.Equal(Personnel.HumanDouble, cockpit.Personnel); Assert.Equal(Personnel.EngineAlien, cabinWithEngineAlien.Personnel); Assert.Equal(Personnel.HumanDouble, cabinWithHumans1.Personnel); Assert.Equal(Personnel.HumanDouble, cabinWithHumans2.Personnel); Assert.Equal(7, ship.CrewCount); //trying to remove 3 crewmembers should succeed Assert.Equal(3, ship.RemovePersonnel(3)); //the removed personnel are prioritised to be the humans outside the cockpit Assert.Equal(4, ship.CrewCount); Assert.Equal(Personnel.EngineAlien, cabinWithEngineAlien.Personnel); Assert.Equal(Personnel.HumanDouble, cockpit.Personnel); //trying to remove further 2, keeping cockpit personnel intact if possible Assert.Equal(2, ship.RemovePersonnel(2)); Assert.Equal(2, ship.CrewCount); Assert.Equal(Personnel.None, cabinWithEngineAlien.Personnel); Assert.Equal(Personnel.HumanDouble, cockpit.Personnel); //trying to remove 3 more, this will empty the cockpit as well //there were only 2 members left Assert.Equal(2, ship.RemovePersonnel(3)); Assert.Equal(0, ship.CrewCount); Assert.Equal(Personnel.None, cockpit.Personnel); }
public void AlienTest() { //ship not able to house alien crew Ship invalidShip = new Ship(ShipLayout.Small, PlayerColor.Blue); //ship able to house alien crew Ship validShip = new Ship(ShipLayout.Small, PlayerColor.Blue); Cabin cabin = new Cabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); EngineCabin engineCabin = new EngineCabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); //parts connected right next to the cockpit(5,5) //on the cockpit's right side is the engineCabin, right below that the other cabin validShip.AddPart(engineCabin, 5, 6); validShip.AddPart(cabin, 6, 6); foreach (Personnel pc in Enum.GetValues(typeof(Personnel))) { //invalidShip can't house any kind of alien, validShip can house engine aliens //(can house humans, which is included, in the Personnel enum, but it auto-returns false) Assert.False(invalidShip.HighlightCabinsForAlien(pc)); if (pc != Personnel.EngineAlien) { Assert.False(validShip.HighlightCabinsForAlien(pc)); } } Assert.True(validShip.HighlightCabinsForAlien(Personnel.EngineAlien)); //trying to insert right personnel to the wrong cabin Assert.False(validShip.AddAlien(5, 6, Personnel.EngineAlien)); //to the cockpit, which even though would be valid as a cabin, but the cockpit explicitly must have humans as personel Assert.False(validShip.AddAlien(5, 5, Personnel.EngineAlien)); //trying to add humans or a laseralien, which's requirement is not met foreach (Personnel pc in Enum.GetValues(typeof(Personnel))) { if (pc != Personnel.EngineAlien) { Assert.False(validShip.AddAlien(6, 6, pc)); } } //adding the actual alien Assert.True(validShip.AddAlien(6, 6, Personnel.EngineAlien)); //only one alien of each type can be housed Assert.False(validShip.AddAlien(6, 6, Personnel.EngineAlien)); }
public void PandemicTest() { Ship ship = new Ship(ShipLayout.Small, PlayerColor.Blue); Cabin cabin1 = new Cabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); Cabin cabin2 = new Cabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); Cabin cabin3 = new Cabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); Part alienCabin = new EngineCabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); //insert cabins, two of them to the right of the cockpit one after another ship.AddPart(cabin1, 5, 6); ship.AddPart(cabin2, 5, 7); //the aliencabin and the cabin right below the 5,6 cabin ship.AddPart(alienCabin, 6, 6); ship.AddPart(cabin3, 7, 6); ship.AddAlien(5, 6, Personnel.EngineAlien); ship.FillCabins(); //check is cabins are correctly filled to begin with Assert.Equal(Personnel.EngineAlien, cabin1.Personnel); Assert.Equal(Personnel.HumanDouble, cabin2.Personnel); Assert.Equal(Personnel.HumanDouble, cabin3.Personnel); Assert.Equal(Personnel.HumanDouble, (ship.GetCockpit() as Cabin).Personnel); //apply the pandemic, ship.ApplyPandemic(); //this should remove one human from cabin2 and the cockpit, and the alien from cabin1, cabin3 should remain intact Assert.Equal(Personnel.None, cabin1.Personnel); Assert.Equal(Personnel.HumanSingle, cabin2.Personnel); Assert.Equal(Personnel.HumanSingle, (ship.GetCockpit() as Cabin).Personnel); Assert.Equal(Personnel.HumanDouble, cabin3.Personnel); //apply the pandemic again ship.ApplyPandemic(); //since cabin 1 is empty, no crew members should be removed Assert.Equal(Personnel.None, cabin1.Personnel); Assert.Equal(Personnel.HumanSingle, cabin2.Personnel); Assert.Equal(Personnel.HumanSingle, (ship.GetCockpit() as Cabin).Personnel); Assert.Equal(Personnel.HumanDouble, cabin3.Personnel); }
public void RemoveAlienCabinTest() { Ship ship = new Ship(ShipLayout.Small, PlayerColor.Blue); //the alien itself is housed in the cabin, the neighbouring alienCabin is the requisite for the cabin to be able to house it Cabin cabin = new Cabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); Part alienCabin = new EngineCabin(Connector.Universal, Connector.Universal, Connector.Universal, Connector.Universal); //add the parts and the alien to the ship ship.AddPart(cabin, 5, 6); ship.AddPart(alienCabin, 5, 7); ship.AddAlien(5, 6, Personnel.EngineAlien); //the alien in fact got added Assert.Equal(Personnel.EngineAlien, cabin.Personnel); //remove the life support unit - the alien should get removed as well ship.RemovePartAtIndex(5, 7); Assert.Equal(Personnel.None, cabin.Personnel); //cabin can no longer house alien Assert.False(ship.AddAlien(5, 6, Personnel.EngineAlien)); }