public bool doTest()
        {
            ReqDisplay.title("Requirement #6");
            ReqDisplay.message("Semi uses to get tokens until a terminator is retrieved");
            var toker = new Toker();

            fileSpec = Path.GetFullPath(fileSpec);
            if (!toker.open(fileSpec))
            {
                Console.Write("\n  toker can't open \"{0}\"", fileSpec);
                return(result = false);
            }

            Console.Write("\n  processing file \"{0}\"", fileSpec);
            var semi = new Semi();

            semi.toker = toker;
            while (!semi.isDone())
            {
                semi.get();
                semi.show();
            }

            return(result);
        }
        public bool doTest()
        {
            ReqDisplay.title("Requirement #10c");
            ReqDisplay.message("Testing semi extraction");

            result = FileUtils.fileLines(fileSpec2);
            if (!result)
            {
                return(false);
            }

            var toker = new Toker();

            toker.doReturnComments = true;
            toker.open(fileSpec2);
            var semi = new Semi();

            semi.toker = toker;

            while (!semi.isDone())
            {
                semi.get();
                replace(semi, "\n", "\\n");
                replace(semi, "\r", "\\r");
                //replace(semi, )
                semi.show();
            }

            return(result);
        }
        public static bool findSequence(bool findAll, params string[] toks)
        {
            var found = false;

            if (!File.Exists(file))
            {
                return(false);
            }
            var semi  = new Semi();
            var toker = new Toker();

            toker.open(file);
            semi.toker = toker;
            while (!semi.isDone())
            {
                semi.get();
                if (semi.hasSequence(toks))
                {
                    semi.show();
                    found = true;
                    if (findAll == false)
                    {
                        return(true);
                    }
                }
            }

            return(found);
        }
예제 #4
0
        //---------------<Exetract type information from collection of files>------------
        public void AnalyzeFiles()
        {
            foreach (string filepath in files_)
            {
                Semi semi = new Semi();
                if (!semi.open(filepath))
                {
                    Console.WriteLine("Cannot open file {0}", filepath);
                    continue;
                }
                string filename = Filename(filepath);

                BuildTypeAnalyzer typeAnalysis = new BuildTypeAnalyzer(semi, filename);
                Parser            typeParser   = typeAnalysis.build();
                try
                {
                    while (semi.get().Count > 0)
                    {
                        typeParser.parse(semi);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
            }
            Repository repo = Repository.getInstance();

            repo.MapAlias();
        }
        ITokenCollection compactGeneric(ITokenCollection semi)
        {
            ITokenCollection aClone = new Semi();
            int start, stop;

            semi.find("<", out start);
            if (start == -1)
            {
                return(semi);
            }
            semi.find(">", out stop);
            if (stop == -1)
            {
                return(semi);
            }
            for (int i = 0; i <= start - 2; ++i)
            {
                aClone.add(semi[i]);
            }
            string newTok = "";

            for (int i = start - 1; i < stop + 1; ++i)
            {
                newTok += semi[i];
            }
            //aClone.add(newTok);
            aClone.add(semi[start - 1]);
            for (int i = stop + 1; i < semi.size(); ++i)
            {
                aClone.add(semi[i]);
            }
            return(aClone);
        }
예제 #6
0
        private ITokenCollection compactGeneric(ITokenCollection semi)
        {
            ITokenCollection aClone = new Semi();
            int start, stop;

            semi.find("<", out start);
            if (start == -1)
            {
                return(semi);
            }
            semi.find(">", out stop);
            if (stop == -1)
            {
                return(semi);
            }
            for (var i = 0; i <= start - 2; ++i)
            {
                aClone.add(semi[i]);
            }
            var newTok = "";

            for (var i = start - 1; i < stop + 1; ++i)
            {
                newTok += semi[i];
            }
            //aClone.add(newTok);  // this comment causes compaction to remove generic params
            aClone.add(semi[start - 1]);
            for (var i = stop + 1; i < semi.size(); ++i)
            {
                aClone.add(semi[i]);
            }
            return(aClone);
        }
예제 #7
0
        public Vehicle CreateVehicle(string type)
        {
            Vehicle vehicle = null;

            switch (type)
            {
            case "Semi":
                vehicle = new Semi();
                break;

            case "Truck":
                vehicle = new Truck();
                break;

            case "Van":
                vehicle = new Van();
                break;

            default:
                throw new InvalidOperationException(
                          string.Format(
                              ExceptionMessages.InvalidType,
                              "vehicle"));
            }

            return(vehicle);
        }
예제 #8
0
        public void TransferSemiFromCenterToCenter()
        {
            var favoriteVehicle = new Semi("Make3", "Model1", "2018", "aabbccdd1122334455668802", VehicleStatusType.StandBy);
            var vehicles1       = new List <Vehicle> {
                new Truck("Make1", "Model1", "2018", "aabbccdd1122334455668899", VehicleStatusType.InService),
                new Van("Make2", "Model1", "2018", "aabbccdd1122334455668800", VehicleStatusType.InTransit),
                new Van("Make2", "Model2", "2018", "aabbccdd1122334455668801", VehicleStatusType.InTransit),
                favoriteVehicle
            };

            var branches1 = new List <Branch>
            {
                new Branch(), new Branch()
            };
            var center1 = new Center(vehicles1, branches1);

            var vehicles2 = new List <Vehicle> {
                new Truck("Make1", "Model1", "2018", "aabbccdd1122334455668844", VehicleStatusType.InService),
                new Van("Make1", "Model2", "2018", "aabbccdd1122334455668855", VehicleStatusType.InTransit),
                new Truck("Make2", "Model1", "2018", "aabbccdd1122334455668866", VehicleStatusType.InService)
            };

            var branches2 = new List <Branch>
            {
                new Branch(), new Branch()
            };
            var center2 = new Center(vehicles2, branches2);;

            center1.TransferSemiToCenter(center2, favoriteVehicle);
        }
 public void ConstructDependency()
 {
     foreach (string filepath in files_)
     {
         Semi semi = new Semi();
         if (!semi.open(filepath))
         {
             Console.WriteLine("Cannot open file {0}", filepath);
             continue;
         }
         string filename = TypeAnalyzer.Filename(filepath);
         //Console.WriteLine(" - Processing file {0}", filename);
         BuildDependencyAnalyzer depAnalyzer = new BuildDependencyAnalyzer(semi, filename);
         Parser depParser = depAnalyzer.build();
         //Console.WriteLine("Size of graph: {0}", graph_.Count);
         try
         {
             while (semi.get().Count > 0)
             {
                 depParser.parse(semi);
             }
         }
         catch (Exception ex)
         {
             Console.Write("\n\n  {0}\n", ex.Message);
         }
     }
 }
예제 #10
0
        public void ExecutarCampeonato(IList <Lutador> lutadoresSelecionados)
        {
            Participantes = lutadoresSelecionados;

            CarregarGrupos();

            foreach (Grupo grupo in Grupos)
            {
                grupo.MontarPartidas();
                grupo.JogarPartidas();
                grupo.EncerrarGrupo();
            }

            //TO-DO Melhorar isso:
            Quarta.Add(new Partida {
                Lutador1 = Grupos[0].PrimeiroLugarGrupo, Lutador2 = Grupos[1].SegundoLugarGrupo
            });
            Quarta.Add(new Partida {
                Lutador1 = Grupos[0].SegundoLugarGrupo, Lutador2 = Grupos[1].PrimeiroLugarGrupo
            });
            Quarta.Add(new Partida {
                Lutador1 = Grupos[2].PrimeiroLugarGrupo, Lutador2 = Grupos[3].SegundoLugarGrupo
            });
            Quarta.Add(new Partida {
                Lutador1 = Grupos[2].SegundoLugarGrupo, Lutador2 = Grupos[3].PrimeiroLugarGrupo
            });

            foreach (Partida quarta in Quarta)
            {
                quarta.Lutar();
            }

            //TO-DO Melhorar isso:
            Semi.Add(new Partida {
                Lutador1 = Quarta[0].Vencedor, Lutador2 = Quarta[1].Vencedor
            });
            Semi.Add(new Partida {
                Lutador1 = Quarta[2].Vencedor, Lutador2 = Quarta[3].Vencedor
            });

            foreach (Partida semi in Semi)
            {
                semi.Lutar();
            }

            //TO-DO Melhorar isso:
            Final.Add(new Partida {
                Lutador1 = Semi[0].Vencedor, Lutador2 = Semi[1].Vencedor
            });
            Final.Add(new Partida {
                Lutador1 = Semi[0].Perdedor, Lutador2 = Semi[1].Perdedor
            });

            foreach (Partida final in Final)
            {
                final.Lutar();
            }

            Encerrar();
        }
        public void RecieveVehicle()
        {
            Semi         mycar          = new Semi("1999", "asdfgsdsafadsfasdas12345", "Nissan", "Altima");
            Distribution myDistribution = new Distribution();

            myDistribution.Recieve(mycar);
            Assert.AreEqual(mycar, myDistribution.Vehicles[0]);
        }
        public void TransferSemiToBranch()
        {
            Semi         mycar = new Semi("1999", "asdfgsdsafadsfasdas12345", "Nissan", "Altima");
            Distribution myDistributionSend = new Distribution();
            Branch       myBranchRecieve    = new Branch();

            myDistributionSend.Transfer(myBranchRecieve, mycar);
        }
예제 #13
0
      public void TestSemiPropertyIsEmptyReturnsCorrectValueWhenNotEmpty()
      {
          Vehicle semi      = new Semi();
          Product hardDrive = new HardDrive(120);

          semi.LoadProduct(new Gpu(100));
          Assert.IsFalse(semi.IsEmpty, "Semi should not be empty");
      }
예제 #14
0
        public void TestLoadProduct()
        {
            Vehicle vehicle = new Semi();

            vehicle.LoadProduct(new Gpu(5));

            Assert.AreEqual(1, vehicle.Trunk.Count);
        }
예제 #15
0
      public void TestSemiPropertyIsFullReturnsCorrectValueWhenNotFull()
      {
          Vehicle semi      = new Semi();
          Product hardDrive = new HardDrive(120);

          semi.LoadProduct(new Gpu(100));
          Assert.False(semi.IsFull, "Semi should not be full");
      }
        public void TransferWithNoVehicle()
        {
            Semi         mycar = new Semi("1999", "asdfgsdsafadsfasdas12345", "Nissan", "Altima");
            Distribution myDistributionSend    = new Distribution();
            Distribution myDistributionRecieve = new Distribution();

            myDistributionSend.Transfer(myDistributionRecieve, mycar);
        }
예제 #17
0
        public void AddVehicleMethodAddsCorrctly()
        {
            Vehicle semi       = new Semi();
            var     method     = typeof(Storage).GetMethod("AddVehicle", BindingFlags.Instance | BindingFlags.NonPublic);
            int     garageSlot = (int)method.Invoke(storage, new object[] { semi });

            Assert.That(garageSlot == 3);
            Assert.That(this.storage.GetVehicle(3) is Semi);
        }
예제 #18
0
      public void TestSemiUnLoadProductThrowsExceptionWhenEmpty()
      {
          Vehicle semi      = new Semi();
          Product hardDrive = new HardDrive(120);

          semi.LoadProduct(new Gpu(100));
          semi.Unload();
          Assert.Throws <InvalidOperationException>(() => semi.Unload(), "Empty Semi still unloads products.");
      }
예제 #19
0
        public void TestProperties()
        {
            Vehicle vehicle = new Semi();

            Assert.AreEqual(10, vehicle.Capacity);
            Assert.AreEqual(true, typeof(Vehicle).GetProperty("Trunk").CanWrite == false);
            Assert.AreEqual(false, vehicle.IsFull);
            Assert.AreEqual(true, vehicle.IsEmpty);
        }
예제 #20
0
        static void Main(string[] args)
        {
            List <Vehicle> parkingLot = new List <Vehicle>();

            Semi semi1 = new Semi("yellow", "Volvo", "VML500", 2015);
            Car  car1  = new Car("black", "Tesla", "S", 2021);

            parkingLot.Add(semi1);
            parkingLot.Add(car1);
        }
예제 #21
0
        public void Consts_AllSpecificVehicles_ShouldSetVehicleCapacityCorrectlyUponInitialisation()
        {
            var semi  = new Semi();
            var truck = new Truck();
            var van   = new Van();

            Assert.AreEqual(10, semi.Capacity, "Semi capacity mismatch when new vehicle is initialised!");
            Assert.AreEqual(5, truck.Capacity, "Truck capacity mismatch when new vehicle is initialised!");
            Assert.AreEqual(2, van.Capacity, "Van capacity mismatch when new vehicle is initialised!");
        }
 public void replace(Semi semi, string toGo, string toPut)
 {
     for (var i = 0; i < semi.size(); ++i)
     {
         if (semi[i] == toGo)
         {
             semi[i] = toPut;
         }
     }
 }
예제 #23
0
      public void TestSemiUnLoadProductUnloadsTheCorretItem()
      {
          Vehicle semi = new Semi();

          Product hardDrive = new HardDrive(120);

          semi.LoadProduct(new Gpu(100));
          semi.LoadProduct(hardDrive);
          Assert.AreEqual(semi.Unload(), hardDrive);
      }
예제 #24
0
      public void TestSemiLoadProductLoadsItems()
      {
          Vehicle semi = new Semi();

          Product gpu = new Gpu(120);

          semi.LoadProduct(gpu);

          Assert.AreEqual(semi.Trunk.First(), gpu, "Semi does not add products correctly.");
      }
예제 #25
0
        static void Main(string[] args)
        {
            Console.WriteLine("Lets Make Vehicles");


            SportsCar   tesla       = new SportsCar();
            Sedan       lumina      = new Sedan();
            PickUp      f150        = new PickUp();
            Semi        mack        = new Semi();
            Gas         gas         = new Gas();
            Electricity electricity = new Electricity();
            Diesel      diesel      = new Diesel();

            var teslaFactory  = new TeslaFactory();
            var luminaFactory = new LuminaFactory();
            var f150Factory   = new F150Factory();
            var mackFactory   = new MackFactory();

            // if you're building a factory this makes sense, you let the door factory make the doors.
            teslaFactory.BuildTesla(tesla);
            luminaFactory.BuildLumina(lumina);
            f150Factory.BuildF150(f150);
            mackFactory.BuildMack(mack);


            // first method, but is it this main method's responsibility to make this?
            //tesla.FrontDoors = new FrontDoors();

            tesla.FrontDoors.FrontDoorsOpen();
            tesla.FrontDoors.FrontDoorsClose();
            tesla.Engine.Go(electricity);
            tesla.Turbo.GoFast();

            lumina.FrontDoors.FrontDoorsOpen();
            lumina.FrontDoors.FrontDoorsClose();
            lumina.BackDoors.BackDoorsOpen();
            lumina.Childseat.ProtectChild();
            lumina.BackDoors.BackDoorsClose();
            lumina.Engine.Go(gas);
            lumina.BackDoors.BackDoorsOpen();
            lumina.Childseat.ProtectChild();
            lumina.BackDoors.BackDoorsClose();

            f150.Bed.Fill();
            f150.FrontDoors.FrontDoorsOpen();
            f150.FrontDoors.FrontDoorsClose();
            f150.Engine.Go(gas);
            f150.Bed.Empty();

            mack.Trailer.Fill();
            mack.FrontDoors.FrontDoorsOpen();
            mack.FrontDoors.FrontDoorsClose();
            mack.Engine.Go(diesel);
        }
예제 #26
0
        private static IEnumerable <Vehicle> InitializeVehicles()
        {
            VehicleFactory vehicleFactory = new VehicleFactory();
            List <Vehicle> ve             = new List <Vehicle>();

            for (int i = 0; i < 3; i++)
            {
                Semi semi = (Semi)vehicleFactory.CreateVehicle("Semi");
                ve.Add(semi);
            }
            return(ve);
        }
예제 #27
0
        public void SemiTest()
        {
            //-- Arrange
            Semi semi1 = new Semi();

            string expected = "Semi capacity is 10";

            //-- Act
            string actual = semi1.description;

            //-- Assert
            Assert.AreEqual(expected, actual);
        }
예제 #28
0
        public void SendVehicleToShouldReturnSuccessfullyCompletionMessage
            (string sourceName, int sourceGarageSlot, string destinationName)
        {
            this.storageMaster.RegisterStorage("Warehouse", "Masterhouse");
            this.storageMaster.RegisterStorage("AutomatedWarehouse", "Baumax");

            var expectedVehicle = new Semi();

            var expectedMessage = $"Sent {expectedVehicle.GetType().Name} to {new AutomatedWarehouse("Baumax").Name} (slot {sourceGarageSlot + 1})";
            var resultMessage   = this.storageMaster.SendVehicleTo(sourceName, sourceGarageSlot, destinationName);

            Assert.AreEqual(expectedMessage, resultMessage);
        }
        public void TransferSemiFromToDistribtion()
        {
            Semi         mycar = new Semi("1999", "asdfgsdsafadsfasdas12345", "Nissan", "Altima");
            Distribution myDistributionSend    = new Distribution();
            Distribution myDistributionRecieve = new Distribution();

            myDistributionSend.Recieve(mycar);
            myDistributionSend.Transfer(myDistributionRecieve, mycar);

            Assert.AreEqual(0, myDistributionSend.Vehicles.Count);
            Assert.AreEqual(1, myDistributionRecieve.Vehicles.Count);
            Assert.AreEqual(mycar, myDistributionRecieve.Vehicles[0]);
        }
예제 #30
0
      public void TestSemiPropertyIsFullReturnsCorrectValueWhenFull()
      {
          Vehicle semi      = new Semi();
          Product hardDrive = new HardDrive(120);

          semi.LoadProduct(hardDrive);
          semi.LoadProduct(hardDrive);
          semi.LoadProduct(hardDrive);
          semi.LoadProduct(hardDrive);
          semi.LoadProduct(hardDrive);
          semi.LoadProduct(hardDrive);
          semi.LoadProduct(hardDrive);
          semi.LoadProduct(hardDrive);
          semi.LoadProduct(hardDrive);
          semi.LoadProduct(hardDrive);
          Assert.True(semi.IsFull, "Semi should be full");
      }