Exemplo n.º 1
0
 public void Test_readMapFromFile_Success()
 {
     try
     {
         GraphMap map = new GraphMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory,FilesDirectories.GraphMap));
     }
     catch (Exception e)
     {
         Assert.Fail("No exception is supposed to be thrown");
     }
 }
Exemplo n.º 2
0
 public void CalcOptimalWays_Successfull()
 {
     string from="Питер";
     string to="Сыктывкар";
     double realDistance = 35;
     GraphMap map = new GraphMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory, FilesDirectories.GraphMap));
     var privateObject = new PrivateObject(map);
     privateObject.Invoke("CalcOptimalWays");
     double gotDistance = map.Distance(from, to);
     Assert.AreEqual(realDistance, gotDistance, 0.01, "Wrong optimal way between 2 points");
 }
Exemplo n.º 3
0
 /// <summary>
 /// Считает стоимость 1 билета
 /// </summary>
 /// <param name="from">Откуда</param>
 /// <param name="to">Куда</param>
 /// <returns>Цена билета</returns>
 /// <exception cref="System.Exception">Ошибка расчёта расстояния или ошибка считывания количества проданных билетов из файла</exception>"
 public override double cost(string from, string to)
 {
     GraphMap map = new GraphMap(FilesDirectories.GraphMap);
     try
     {
         return fuelConsumption * fuelprice * map.Distance(from, to) / SoldTickets(FilesDirectories.GroundTransportTickets);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 4
0
 public void BuildGroundRace_Successfull()
 {
     GraphMap map = new GraphMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory, FilesDirectories.GraphMap));
     var privateObject = new PrivateObject(map);
     try
     {
         privateObject.Invoke("BuildGroundRace", "Москва", "Питер");
     }
     catch (Exception e)
     {
         Assert.Fail("No exception is supposed to be thrown");
     }
 }
Exemplo n.º 5
0
 public void BuildGroundRace_Failed2()
 {
     GraphMap map = new GraphMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory, FilesDirectories.GraphMap));
     var privateObject = new PrivateObject(map);
     try
     {
         privateObject.Invoke("BuildGroundRace", "Москва", "Непал");
         //Assert.Fail(GraphMap.PointsDoesntCommunicate); //Можно так вместо StringAssert
     }
     catch (Exception e)
     {
         StringAssert.Contains(e.Message, GraphMap.PointsDoesntCommunicate);
         return;
     }
     Assert.Fail("Exception is supposed to be thrown");
 }
Exemplo n.º 6
0
 public void Test_readMapFromFile_Fail()
 {
     try
     {
         GraphMap map = new GraphMap(FilesDirectories.getFilePath(FilesDirectories.GraphMapTestDirectory,FilesDirectories.GraphMapTest));
     }
     catch (FormatException e)
     {
         StringAssert.Contains(e.Message, GraphMap.ErrorReadFile);
         return;
     }
     catch (OverflowException e)
     {
         StringAssert.Contains(e.Message, GraphMap.TooBigValueInFile);
         return;
     }
     catch (ArgumentNullException e)
     {
         StringAssert.Contains(e.Message, GraphMap.InternalErrorFileReading);
         return;
     }
     Assert.Fail("Exception is supposed to be thrown");
 }
Exemplo n.º 7
0
 /// <summary>
 /// Расчёт стоимости 1 билета из одного пункта в другой
 /// </summary>
 /// <param name="from">Откуда</param>
 /// <param name="to">Куда</param>
 /// <returns></returns>
 public override double cost(string from, string to)
 {
     GraphMap map = new GraphMap(FilesDirectories.GraphMap);
     return fuelConsumption * fuelprice * map.Distance(from, to) / ticketsQuantity;
 }
Exemplo n.º 8
0
 public void Communicate_True()
 {
     GraphMap map = new GraphMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory, FilesDirectories.GraphMap));
     Assert.IsTrue(map.Communicate("Москва", "Кировск"));
 }
Exemplo n.º 9
0
 public void Communicate_False()
 {
     GraphMap map = new GraphMap(FilesDirectories.getFilePath(FilesDirectories.Лаба1оDirectory, FilesDirectories.GraphMap));
     Assert.IsFalse(map.Communicate("Москва", "Мвен-Дитю"));
 }