public void CheckInfectedTest()
 {
     Computer comp = new Computer(new Windows(), false);
     Random rand = new Random(1);
     for (int i = 0; i < 10; i++)
     {
         comp.CheckInfection(rand);
     }
     Assert.IsFalse(comp.Infected);
     comp.CheckInfection(rand);
     Assert.IsTrue(comp.Infected);
 }
Exemple #2
0
 /// <summary>
 /// Cоздание массива компьютеров
 /// </summary>
 private void CreateArrayOfComputers()
 {
     for (int i = 0; i < NumberOfComputers; i++)
     {
         string line = text.ReadLine();
         string[] parsedLine = line.Split(' ');
         if (parsedLine.Count() > 3)
         {
             throw new IncorrectInputDataException();
         }
         OS installedOs = default(OS);
         switch (parsedLine[0])
         {
             case "Windows":
                 installedOs = new Windows();
                 break;
             case "MacOS":
                 installedOs = new MacOS();
                 break;
             case "Linux":
                 installedOs = new Linux();
                 break;
             default:
                 throw new IncorrectInputDataException();
         }
         ArrayOfComputer[i] = new Computer(installedOs, parsedLine[1] == "1");
     }
 }
Exemple #3
0
 /// <summary>
 /// Метод для чтения информации из файла
 /// </summary>
 private void ReadingTextFile()
 {
     NumberOfComputers = GetNumberOfComputers();
     ArrayOfComputer = new Computer[NumberOfComputers];
     CreateArrayOfComputers();
     Graph = new GraphOfNetwork(NumberOfComputers);
     CreateGraph();
 }