public void TestMethod1()
        {
            //Dodajemo jedno vozilo u repozitorij, zatim testiramo hoće li na repozitorij ispravno vratiti kolko ima slobodnih vozila

            //isto provjeravamo nakon što dodamo zaposlenike na put

            //arrange

            Employee e1 = new Employee("12348501236", "Jelena", "Cvitanović", "Indirektna prodaja", "0989036876", "*****@*****.**");
            Employee e2 = new Employee("","Pero", "Perić", "Financije", "0977253426", "*****@*****.**");
            Employee e3 = new Employee("","Mirna", "Mirić", "IT", "0912542456", "*****@*****.**");
            City city = new City("Zagreb", "Croatia");
            City city2 = new City("Ljubljana", "Slovenia");

            int expected = 0;
            Vehicle v = new Vehicle(VehicleType.car, "Toyota",2, 7, city);
            Trip t = new Trip(e1, v, DateTime.Today, city, city2, 100);
            TripRepository.GetInstance().addTrip(t);

            //act

            VehicleRepository.GetInstance().AddNewVehicle(v);
            int actual = VehicleRepository.GetInstance().GetAvailableCount();

            t.addTraveller(e2);
            int actual2 = TripRepository.GetInstance().getNotFullOnesCount();

            //assert

            Assert.AreEqual(expected, actual, "Repozitorij ne prepoznaje ispravno slobodna vozila.");
            Assert.AreEqual(0, actual2, "Repozitorij ne prepoznaje ispravno slobodna vozila2.");
        }
        public void TestMethod2()
        {
            //arrange

            Employee e1 = new Employee("12348501236","Jelena", "Cvitanović", "Indirektna prodaja", "0989036876", "*****@*****.**");
            Employee e2 = new Employee("","Pero", "Perić", "Financije", "0977253426", "*****@*****.**");
            City city = new City("Zagreb", "Croatia");
            City city2 = new City("Ljubljana", "Slovenia");

            Vehicle v = new Vehicle(VehicleType.car, "Toyota", 2, 7, city);
            Trip t = new Trip(e1, v, DateTime.Today, city, city2, 100);
            TripRepository.GetInstance().addTrip(t);

            //act

            VehicleRepository.GetInstance().AddNewVehicle(v);
            t.addTraveller(e2);

            string name = t.TripOwner.Name;
            string expected = "Jelena";

            //assert

            Assert.AreEqual(expected, name, "Neispravno registriran inicijator puta.");
        }
 public AlternativeTripInfo(TripTypes type, float cost, Employee traveller, City departure, City destination)
 {
     this.TripType = type;
     this.TripCost = cost;
     this.Traveller = traveller;
     this.DepartureCity = departure;
     this.DestinationCity = destination;
     this.Approved = false;
 }
示例#4
0
 //Vehicle(id, type, model, c, consum, city)
 public Vehicle(VehicleType type, string model, int c, float consum, City city)
 {
     this.ID = lastID;
     lastID++;
     this.Type = type;
     this.Model = model;
     this.Capacity = c;
     this.Consumption = consum;
     this.BasicLocation = city;
     this.Adress = "";
     this.IsAvailable = true;
 }
        public void TestMethod3()
        {
            //arrange

            Employee e1 = new Employee("12348501236", "Jelena", "Cvitanović", "Indirektna prodaja", "0989036876", "*****@*****.**");
            City city = new City("Zagreb", "Croatia");
            City city2 = new City("Ljubljana", "Slovenia");

            Vehicle v = new Vehicle(VehicleType.car, "Toyota", 2, 7, city);
            Trip t = new Trip(e1, v, DateTime.Today, city, city2, 100);
            VehicleRepository.GetInstance().AddNewVehicle(v);
            TripRepository.GetInstance().addTrip(t);

            t.Vehicle.IsAvailable = true; //ovo će inače kontroler raditi
            int expected = 1;

            //act
            int actual = VehicleRepository.GetInstance().GetAvailableCount();

            //assert
            Assert.AreEqual(expected, actual, "Vozilo nije vraćeno u slobodne");
        }
示例#6
0
 public Trip(Employee init, Vehicle v, DateTime date, City departure, City destination, long length)
 {
     this.ID = lastID;
     lastID++;
     this.TripOwner = init;
     this.departureDate = date;
     this.DepartureCity = departure;
     this.DestinationCity = destination;
     this.IsAprooved = false;
     this.Vehicle = v;
     this.Travellers = new List<Employee>();
     this.Stops = new List<TripStops>();
     this.isFull = false; //nijedno vozilo nije kapaciteta točno jedan
     this.TripLength = length;
     this.TripCost = length * v.Consumption * avgCost; //informacija za menadžera
     TripStops tmp = new TripStops(DepartureCity, date, 1);
     this.addStop(tmp); //što s destinationom? što je s povratnom rutom? razraditi!
     this.addTraveller(init);
     TripStops tmpStop = new TripStops(DestinationCity, departureDate.AddDays(1),1);
     this.addStop(tmpStop);
     this.Vehicle.IsAvailable = false; //zauzmi vozilo
     this.TripOwner.AddTripInit(this);
     this.isDone = false;
 }
示例#7
0
        //dodati get trip by id
        public void Load()
        {
            City c = new City("Karlovac","Croatia");
            TripStops t = new TripStops(c,new DateTime(2013, 3, 15, 18, 30, 00), 2);
            Trip trip = new Trip(EmployeeRepository.GetInstance().getEmployeeByOib("10257841210"), VehicleRepository.GetInstance().getVehicleByID(1),new DateTime(2013, 3, 15, 17, 30, 00), new City("Zagreb", "Croatia"), new City("Gospić", "Croatia"),100);
            trip.addStop(t);
            TripRepository.GetInstance().addTrip(trip);

            c = new City("Zaprešić", "Croatia");
            t = new TripStops(c, DateTime.Today, 2);
            trip = new Trip(EmployeeRepository.GetInstance().getEmployeeByOib("10778125367"), VehicleRepository.GetInstance().getVehicleByID(1), new DateTime(2012, 4, 10, 18, 50, 0), new City("Zagreb", "Croatia"), new City("Gospić", "Croatia"), 100);
            trip.addStop(t);
            trip.addTraveller(EmployeeRepository.GetInstance().getEmployeeByOib("77812541042"));
            TripRepository.GetInstance().addTrip(trip);

            c = new City("Zagreb", "Croatia");
            t = new TripStops(c, DateTime.Today, 2);
            trip = new Trip(EmployeeRepository.GetInstance().getEmployeeByOib("77812541042"), VehicleRepository.GetInstance().getVehicleByID(2), new DateTime(2013,4,5,10,30,0), new City("Osijek", "Croatia"), new City("Gospić", "Croatia"), 200);
            trip.addStop(t);
            //10234781881
            trip.addTraveller(EmployeeRepository.GetInstance().getEmployeeByOib("10257841210"));
            trip.addTraveller(EmployeeRepository.GetInstance().getEmployeeByOib("10234781881"));
            TripRepository.GetInstance().addTrip(trip);
        }
示例#8
0
 //služit će za padajući izbornik kod prikaza - korisnici će birati samo od ponuđenih gradova
 //gradove dodaje menadžer
 public void addCity(string cityName, string countryName)
 {
     City tmp = new City(cityName, countryName);
     listCities.Add(tmp);
 }
示例#9
0
 public TripStops(City city, DateTime date, int hrs)
 {
     this.City = city;
     this.TripDate = date;
     this.MaxHrsStay = hrs;
 }
        public void TestMethod6()
        {
            //arrange

            Employee e1 = new Employee("12348501236","Jelena", "Cvitanović", "Indirektna prodaja", "0989036876", "*****@*****.**");
            Employee e2 = new Employee("", "Pero", "Perić", "Financije", "0977253426", "*****@*****.**");
            City city = new City("Zagreb", "Croatia");
            City city2 = new City("Ljubljana", "Slovenia");
            e1.removeAllTrips();
            e2.removeAllTrips();
            Vehicle v = new Vehicle(VehicleType.car, "Toyota", 2, 7, city);
            VehicleRepository.GetInstance().RemoveAllVehicles();
            VehicleRepository.GetInstance().AddNewVehicle(v);

            Trip t = new Trip(e1, v, DateTime.Today, city, city2, 100);
            t.addTraveller(e2);
            TripStops stop1 = new TripStops(new City("Karlovac", "Croatia"), DateTime.Today, 4);
            t.addStop(stop1);

            //act

            int check = t.Stops.Count();

            //assert

            Assert.AreEqual(2, check, "Nesipravno bilježnjenje rute");
        }
        public void TestMethod5()
        {
            //arrange

            Employee e1 = new Employee("12348501236","Jelena", "Cvitanović", "Indirektna prodaja", "0989036876", "*****@*****.**");
            Employee e2 = new Employee("","Pero", "Perić", "Financije", "0977253426", "*****@*****.**");
            City city = new City("Zagreb", "Croatia");
            City city2 = new City("Ljubljana", "Slovenia");
            e1.removeAllTrips();
            e2.removeAllTrips();
            Vehicle v = new Vehicle(VehicleType.car, "Toyota", 2, 7, city);

            VehicleRepository.GetInstance().RemoveAllVehicles();
            VehicleRepository.GetInstance().AddNewVehicle(v);

            Trip t = new Trip(e1, v, DateTime.Today, city, city2, 100);
            t.addTraveller(e2);

            //act

            int check = e2.ParticipatedTripList.Count();
            int check2 = e2.InitiatedTripList.Count();

            //assert

            Assert.AreEqual(1, check, "Nesipravno bilježnjenje putovanja na kojem je zaposlenik sudjelovao");
            Assert.AreEqual(0, check2, "Nesipravno bilježnjenje putovanja koje je zaposlenik inicirao");
        }
        public void TestMethod4()
        {
            //arrange

            Employee e3 = new Employee("12348501236", "Jelena", "Cvitanović", "Indirektna prodaja", "0989036876", "*****@*****.**");
            Employee e2 = new Employee("","Pero", "Perić", "Financije", "0977253426", "*****@*****.**");
            City city = new City("Zagreb", "Croatia");
            City city2 = new City("Ljubljana", "Slovenia");

            Vehicle v = new Vehicle(VehicleType.car, "Toyota", 2, 7, city);
            Vehicle v2 = new Vehicle(VehicleType.car, "Toyota", 4, 7, city);
            Vehicle v3 = new Vehicle(VehicleType.caravan, "Toyota", 8, 12, city);

            VehicleRepository.GetInstance().RemoveAllVehicles();

            VehicleRepository.GetInstance().AddNewVehicle(v);
            VehicleRepository.GetInstance().AddNewVehicle(v2);
            VehicleRepository.GetInstance().AddNewVehicle(v3);

            Trip t = new Trip(e3, v, DateTime.Today, city, city2, 100);
            //što kada pokušaš zauzeti već zauzeti auto? - dodati provjeru i/li exception!
            Trip t1 = new Trip(e3, v2, DateTime.Today, city, city2, 100);
            Trip t2 = new Trip(e3, v3, DateTime.Today, city, city2, 100);

            t2.addTraveller(e2);

            //act
            int actual = VehicleRepository.GetInstance().GetAvailableCount();
            int initiCnt = e3.InitiatedTripList.Count();
            int partCnt = e3.ParticipatedTripList.Count();
            int initCnt1 = e2.InitiatedTripList.Count();
            int tripCnt = t.getTravellersCount();
            int trip2Cnt = t2.getTravellersCount();

            //assert
            Assert.AreEqual(0, actual, "Neispravan broj slobodnih vozila");
            Assert.AreEqual(3, initiCnt, "Neispravan broj iniciranih putovanja");
            Assert.AreEqual(0, partCnt, "Neispravan broj putovanja na kojima je zaposlenik sudjelovao");
            Assert.AreEqual(0, initCnt1, "Neispravan broj iniciranih putovanja2");
            Assert.AreEqual(1, tripCnt, "Neispravan broj putnika");
            Assert.AreEqual(2, trip2Cnt, "Neispravan broj putnika2");
        }
        public void Load()
        {
            City city = new City("Zagreb", "Croatia");
            Vehicle v = VehicleFactory.CreateVehicleWithNoInfoAdress(VehicleType.caravan, "Toyota Auris", 6, 9, city);
            VehicleRepository.GetInstance().AddNewVehicle(v);

            city = new City("Karlovac", "Croatia");
            v = VehicleFactory.CreateVehicleWithNoInfoAdress( VehicleType.car, "Toyota Yaris", 4, 7, city);
            VehicleRepository.GetInstance().AddNewVehicle(v);

            city = new City("Gospić", "Croatia");
            v = VehicleFactory.CreateVehicleWithNoInfoAdress( VehicleType.car, "Toyota Yaris", 4, 7, city);
            VehicleRepository.GetInstance().AddNewVehicle(v);

            city = new City("Zagreb", "Croatia");
            v = VehicleFactory.CreateVehicleWithNoInfoAdress( VehicleType.car, "Toyota Yaris", 4, 7, city);
            VehicleRepository.GetInstance().AddNewVehicle(v);
        }
示例#14
0
 public static Vehicle CreateVehicleWithNoInfoAdress(VehicleType type, string model, int c, float consum, City city)
 {
     return new Vehicle(type, model, c, consum, city);
 }