public void GetConsumablesTest() { //// Arrange string name = "test1"; string mglt = "100"; string consumables = "1 day"; var starshipEntity = new StarshipEntity(name, mglt, consumables); //// Act var starshipEntityConsumables = starshipEntity.GetConsumables(); //// Assert Assert.AreEqual(consumables, starshipEntityConsumables); }
public void StarshipEntityTest_ConsumablesIsNull() { //// Arrange string name = "test1"; string mglt = "100"; string consumables = null; //// Act var starshipEntity = new StarshipEntity(name, mglt, consumables); //// Assert Assert.AreEqual(name, starshipEntity.GetName()); Assert.AreEqual(string.Empty, starshipEntity.GetConsumables()); Assert.AreEqual(Convert.ToInt32(mglt), starshipEntity.GetMGLT()); }
public void StarshipEntityTest_NameIsUnkown(string value) { //// Arrange string name = value; string mglt = "100"; string consumables = "1 day"; //// Act var starshipEntity = new StarshipEntity(name, mglt, consumables); //// Assert Assert.AreEqual(string.Empty, starshipEntity.GetName()); Assert.AreEqual(consumables, starshipEntity.GetConsumables()); Assert.AreEqual(Convert.ToInt32(mglt), starshipEntity.GetMGLT()); }
public KeyValuePair <string, string> CalculateNumberOfResupplyStopsNeeded(StarshipEntity starship, int distance) { var totalHoursOfConsumables = _calculationService.GetConsumablesInHours(starship.GetConsumables()); var totalHoursOfTravel = _calculationService.GetTotalHoursToTravel(distance, starship.GetMGLT()); if (totalHoursOfConsumables == null || totalHoursOfTravel == null) { return(new KeyValuePair <string, string>(starship.GetName(), "unknown")); } else { var numberOfStopsRequired = totalHoursOfTravel.Value / totalHoursOfConsumables.Value; return(new KeyValuePair <string, string>(starship.GetName(), numberOfStopsRequired.ToString())); } }