public void readMapFromFile_Successful() { try { AirMap map = new AirMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory, FilesDirectories.AirMap)); } catch (Exception e) { Assert.Fail("No exception should appear"); } }
public void Distance_Successful() { AirMap map = new AirMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory,FilesDirectories.AirMap)); try { map.Distance("Москва", "Питер"); } catch (Exception e) { Assert.Fail("Error"); } }
public void readMapFromFile_Fail() { try { AirMap map = new AirMap(FilesDirectories.getFilePath(FilesDirectories.AirMapTestDirectory, FilesDirectories.AirMapTest)); } catch (Exception e) { StringAssert.Contains(e.Message, AirMap.ErrorReadingMapFromFile); return; } Assert.Fail("No exception was thrown"); }
public void BuildAirRace_Failed2() { AirMap map = new AirMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory, FilesDirectories.AirMap)); var privateObject = new PrivateObject(map); try { privateObject.Invoke("BuildAirRace", "Москва", "Мали"); Assert.Fail("Error"); } catch (Exception e) { StringAssert.Contains(e.Message, AirMap.AirportsDoesntCommunicate); } }
public void Distance_Fail2() { AirMap map = new AirMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory, FilesDirectories.AirMap)); try { map.Distance("Москва", "Токио"); } catch (Exception e) { StringAssert.Contains(e.Message, AirMap.AirportsDoesntCommunicate); return; } Assert.Fail(AirMap.AirportsDoesntCommunicate); }
public void BuildAirRace_Successful() { AirMap map = new AirMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory,FilesDirectories.AirMap)); var privateObject = new PrivateObject(map); try { privateObject.Invoke("BuildAirRace", "Москва", "Алушта"); Assert.Fail(AirMap.AirportsDoesntCommunicate); } catch (Exception e) { if (e.GetType() is AssertFailedException) { Assert.Fail("Something is wrong in BuildAirRace"); } } }
/// <summary> /// Расчёт стоимости проезда из пункта 1 в пункт 2 /// </summary> /// <param name="from">Откуда</param> /// <param name="to">Куда</param> /// <returns>Стоимость</returns> /// <exception cref="System.Exception">Ошибка расчёта расстояния между пунктами</exception>" /// <exception cref="System.Exception">Ошибка чтения цен топлива из файла</exception>" public override double cost(string from, string to) { //string mapPath;//Куда всунуть path или саму map. В параметры cost или локальными переменными cost? AirMap map = new AirMap(FilesDirectories.AirMap); double distance; try { distance = map.Distance(from, to); } catch (Exception) { throw new Exception("2 airports doesn't communicate"); } try { OilPrices oilprice = new OilPrices(FilesDirectories.OilPrices); } catch (Exception) { throw new Exception("Error reading oil prices"); } return fuelConsumption * OilPrices.getPrice(oilType) * distance / ticketsQuantity;//Можно добавить +luggage+takeoff+посадка }
public void Test_Communicate_Successful() { AirMap map = new AirMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory,FilesDirectories.AirMap)); Assert.IsFalse(!map.Communicate("Алушта", "Питер")); }
public void Test_Communicate_Failed2() { AirMap map = new AirMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory, FilesDirectories.AirMap)); Assert.IsFalse(map.Communicate("Токио", "Мали")); }