예제 #1
0
        public void TryAddVehicle_AddedVehiclesToPartialyFullLot_IsTrue()
        {
            // Assign
            ParkingLot testLot = new ParkingLot();

            ParkingSlot[] testSlots     = new ParkingSlot[4];
            Vehicle[]     vehList       = new Vehicle[6];
            int           actualValue   = 0;
            int           expectedValue = 6;

            vehList[0] = new Car("A1");
            vehList[1] = new Mc("A2");
            vehList[2] = new Mc("A4");
            vehList[3] = new Trike("A5");
            vehList[4] = new Bike("A6");
            vehList[5] = new Bike("A7");
            int temp;

            // Act
            testLot.TryAddVehicle(vehList[0], out temp);
            testLot.TryAddVehicle(vehList[1], out temp);
            testLot.TryAddVehicle(vehList[2], out temp);
            testLot.TryAddVehicle(vehList[3], out temp);
            testLot.TryAddVehicle(vehList[4], out temp);
            testLot.TryAddVehicle(vehList[5], out temp);
            for (int i = 0; i < 4; i++)
            {
                testSlots[i] = (ParkingSlot)testLot.Content().GetValue(i);
            }
            // Assert
        }
예제 #2
0
        public void RemoveVehicle_IfRemovedVehicleIsRemoved_IsTrue()
        {
            // Assign
            ParkingSlot slot       = new ParkingSlot();
            Bike        bike1      = new Bike("B1");
            Bike        bike2      = new Bike("B2");
            Bike        bike3      = new Bike("B3");
            Bike        bike4      = new Bike("B4");
            bool        actualBool = false;

            // Act
            slot.AddVehicle(bike1);
            slot.AddVehicle(bike2);
            slot.AddVehicle(bike3);
            slot.AddVehicle(bike4);

            slot.RemoveVehicle("B1");

            // Assert
            if (!slot.Content().Contains(bike1) && slot.Content().Contains(bike2))
            {
                actualBool = true;
            }
            Assert.AreEqual(true, actualBool);
        }
예제 #3
0
        public object GetFullName(int z)
        {
            ParkingSlot item = _context.ParkingSlot.Single(p => p.ParkingID == z);

            fullname = item.Plate;
            return(fullname);
        }
예제 #4
0
        private void UpdateParkingSlot(Guid parkingSlotId, object @event)
        {
            ParkingSlot parkingSlot = FindParkingSlot(parkingSlotId);

            if (parkingSlot == null)
            {
                throw new InvalidOperationException("Cannot find slot");
            }

            if (parkingSlot.isOccupied && @event is Events.BookParkingSlot)
            {
                throw new InvalidOperationException("Parking slot is not available for booking");
            }

            if (!parkingSlot.isOccupied && @event is Events.ReleaseParkingSlot)
            {
                throw new InvalidOperationException("Parking slot is not booked");
            }

            if (@event is Events.BookParkingSlot)
            {
                var e = @event as Events.BookParkingSlot;
                if (FindParkingSlipbyVehicleNumber(e.VehicleNumber, e.ParkingLotId) != null)
                {
                    throw new InvalidOperationException("Double booking not allowed");
                }
            }

            if (@event is Events.ReleaseParkingSlot)
            {
                ((Events.ReleaseParkingSlot)@event).ParkingSlipId = parkingSlot.ParkingSlipId;
            }

            ApplyToEntity(parkingSlot, @event);
        }
예제 #5
0
        public override async Task <int> CreateAsync(IServiceInputModel servicesInputViewModel)
        {
            var parking = servicesInputViewModel.To <Parking>();

            await this.parkingRepository.AddAsync(parking);

            var resultOne = await this.parkingRepository.SaveChangesAsync();

            var lastParking = await this.parkingRepository.All().FirstOrDefaultAsync(p => p.Name == parking.Name);

            for (int i = 0; i < lastParking.Capacity; i++)
            {
                var parkingSlot = new ParkingSlot
                {
                    Number    = i,
                    Status    = Status.Free,
                    ParkingId = lastParking.Id,
                };

                await this.parkingSlotRepository.AddAsync(parkingSlot);
            }

            var resultTwo = await this.parkingSlotRepository.SaveChangesAsync();

            return(resultOne + resultTwo);
        }
예제 #6
0
 public static void Add(ParkingSlot parkingSlot)
 {
     using (var conn = new SqliteContext())
     {
         conn.ParkingSlots.Add(parkingSlot);
         conn.SaveChanges();
     }
 }
예제 #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            ParkingSlot parkingSlot = db.ParkingSlots.Find(id);

            db.ParkingSlots.Remove(parkingSlot);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #8
0
        public void ParkingSlotRemoveVehicleCarNotFoundTest()
        {
            // Setup
            string registrationNumber = "abc123";
            string parkingSlot        = "poi654,1999-01-02 13:34";

            // Act
            ParkingSlot.RemoveVehicle(ref parkingSlot, registrationNumber);
        }
 public ParkingSlotVM(ParkingSlot ps) : this()
 {
     IsOccupied = ps.IsOccupied;
     Pts        = new ObservableCollection <Point>(ps.Contour.Select(point => new Point()
     {
         X = point.X,
         Y = point.Y,
     }));
 }
예제 #10
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            MovingCar = GetHitCar();

            //not moving cars, hehe
            if (MovingCar == null)
            {
                ParkingSlot slot = GetHitParkSlot();
                if (slot != null && slot.Unlocked == false)
                {
                    if (moneyController.Money >= ParkingSlot.UnlockPrice)
                    {
                        moneyController.Money -= ParkingSlot.UnlockPrice;
                        slot.Unlock();
                        boughtSound.Play();
                        if (SpotBought != null)
                        {
                            SpotBought();
                        }
                    }
                }
            }
        }
        else if (Input.GetMouseButton(0))
        {
            if (MovingCar != null)
            {
                Vector3 newPos = cam.ScreenToWorldPoint(Input.mousePosition);
                MovingCar.transform.position = new Vector3(newPos.x, newPos.y, 0);
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            if (MovingCar != null)
            {
                ParkingSlot slot = GetHitParkSlot();
                if (slot != null && slot.Occupied == null && slot.Unlocked)
                {
                    if (slot.CanGetAssigned(MovingCar) == false)
                    {
                        ReturnCar();
                        return;
                    }
                    SetCarToNewSlot(slot);
                    if (slot is IdleSlot && ((IdleSlot)slot).SlotType == IdleSlot.IdleSlotType.DepartSlot)
                    {
                        departureSound.Play();
                    }
                    return;
                }
                ReturnCar();
            }
        }
    }
예제 #11
0
    private void SetCarToNewSlot(ParkingSlot newSlot)
    {
        MovingCar.transform.position = newSlot.transform.position;
        MovingCar.transform.rotation = newSlot.transform.rotation;
        MovingCar.slot.Occupied      = null;
        newSlot.Occupied             = MovingCar;
        MovingCar.slot = newSlot;

        MovingCar = null;
    }
예제 #12
0
        public void AddVehicle_IfVehicleDoesFit_IsTrue()
        {
            // Assign
            ParkingSlot slot = new ParkingSlot();
            Car         car  = new Car("ABC123");

            // Act
            slot.AddVehicle(car);
            // Assert
            Assert.AreEqual(true, slot.Content().Contains(car));
        }
        public ParkingAddView(ParkingSlot parkingSlot)
        {
            InitializeComponent();

            ParkingAddId.Text          = parkingSlot.Id.ToString();
            ParkingAddOznaczenie.Text  = parkingSlot.SlotCode.ToString();
            ParkingAddZajete.IsChecked = parkingSlot.Occupied;

            ParkingAddModBtn.Content = "Modyfikuj";
            IdStack.Visibility       = Visibility.Visible;
        }
예제 #14
0
 public ActionResult Edit([Bind(Include = "ParkingSlotID,OwnerID,ParkingSlotAddress,SlotNumber,AvailableStartDate,AvailableEndDate,value,Latitude,Longitude,StartTime,EndTime")] ParkingSlot parkingSlot)
 {
     if (ModelState.IsValid)
     {
         db.Entry(parkingSlot).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OwnerID = new SelectList(db.Owners, "OwnerID", "OwnerName", parkingSlot.OwnerID);
     return(View(parkingSlot));
 }
예제 #15
0
        public void AddVehicle_IfVehicleDoesNotFit_IsTrue()
        {
            // Assign
            ParkingSlot slot = new ParkingSlot();
            Car         car  = new Car("ABC123");
            Bike        bike = new Bike("BCA123");

            // Act
            slot.AddVehicle(car);
            slot.AddVehicle(bike);
            // Assert
        }
예제 #16
0
        public void ParkingSlotRemoveVehicleCarFoundTest()
        {
            // Setup
            string registrationNumber  = "poi654";
            string parkingSlot         = "poi654,1999-01-02 13:34";
            string expectedParkingSlot = null;

            // Act
            ParkingSlot.RemoveVehicle(ref parkingSlot, registrationNumber);

            // Verify
            Assert.AreEqual(expectedParkingSlot, parkingSlot);
        }
예제 #17
0
        public void ParkingSlotRemoveVehicleNullTest()
        {
            // Setup
            string registrationNumber  = "abc123";
            string parkingSlot         = null;
            string expectedParkingSlot = null;

            // Act
            ParkingSlot.RemoveVehicle(ref parkingSlot, registrationNumber);

            // Verify
            Assert.AreEqual(expectedParkingSlot, parkingSlot);
        }
예제 #18
0
        public void ParkingSlotRemoveVehicleLeftTest()
        {
            // Setup
            string registrationNumber  = "lkj987";
            string parkingSlot         = "lkj987:abc123";
            string expectedParkingSlot = ":abc123";

            // Act
            ParkingSlot.RemoveVehicle(ref parkingSlot, registrationNumber);

            // Verify
            Assert.AreEqual(expectedParkingSlot, parkingSlot);
        }
예제 #19
0
        public void GetVehicleTypeOfParkedVehicleNullTest()
        {
            // Setup
            VehicleType expectedVehicleType = VehicleType.Car;
            VehicleType actualVehicleType;
            string      registrationNumber = "abc123";

            string parkingSlot = null;

            // Act
            actualVehicleType = ParkingSlot.GetVehicleTypeOfParkedVehicle(parkingSlot, registrationNumber);
            // Should throw exception
        }
        public async Task <int> SeedParkingSlotsAsync(ApplicationDbContext context)
        {
            var parkingSlots = new ParkingSlot[]
            {
                new ParkingSlot()
                {
                    ParkingId = 1
                },
                new ParkingSlot()
                {
                    ParkingId = 1
                },
                new ParkingSlot()
                {
                    ParkingId = 1
                },
                new ParkingSlot()
                {
                    ParkingId = 1
                },
                new ParkingSlot()
                {
                    ParkingId = 2
                },
                new ParkingSlot()
                {
                    ParkingId = 2
                },
                new ParkingSlot()
                {
                    ParkingId = 2
                },
                new ParkingSlot()
                {
                    ParkingId = 3
                },
                new ParkingSlot()
                {
                    ParkingId = 3
                },
            };

            foreach (var parkingSlot in parkingSlots)
            {
                await context.ParkingSlots.AddAsync(parkingSlot);
            }

            await context.SaveChangesAsync();

            return(parkingSlots.Length);
        }
예제 #21
0
        // GET: ParkingSlots/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ParkingSlot parkingSlot = db.ParkingSlots.Find(id);

            if (parkingSlot == null)
            {
                return(HttpNotFound());
            }
            return(View(parkingSlot));
        }
        public void ParkingIsFreeFor_Mc2McTest()
        {
            // Setup
            VehicleType vehicle     = VehicleType.Mc;
            string      parkingSlot = "abc987:iuy654";
            bool        expected    = false;
            bool        actual;

            // Act
            actual = ParkingSlot.IsFreeFor(parkingSlot, vehicle);

            // Verify
            Assert.AreEqual(expected, actual);
        }
        public void ParkingIsFreeFor_Car1Test()
        {
            // Setup
            VehicleType vehicle     = VehicleType.Car;
            string      parkingSlot = "abc123";
            bool        expected    = false;
            bool        actual;

            // Act
            actual = ParkingSlot.IsFreeFor(parkingSlot, vehicle);

            // Verify
            Assert.AreEqual(expected, actual);
        }
        public void ParkingIsFreeForMc_FreeTest()
        {
            // Setup
            VehicleType vehicle     = VehicleType.Mc;
            string      parkingSlot = null;
            bool        expected    = true;
            bool        actual;

            // Act
            actual = ParkingSlot.IsFreeFor(parkingSlot, vehicle);

            // Verify
            Assert.AreEqual(expected, actual);
        }
예제 #25
0
        public void CountMcNullTest()
        {
            //Setup
            string parkingPlace;

            parkingPlace = null;
            int expectedCount = 0;
            int actualCount;

            //Act
            actualCount = ParkingSlot.CountMc(parkingPlace);

            //Verify
            Assert.AreEqual(expectedCount, actualCount);
        }
예제 #26
0
        // GET: ParkingSlots/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ParkingSlot parkingSlot = db.ParkingSlots.Find(id);

            if (parkingSlot == null)
            {
                return(HttpNotFound());
            }
            ViewBag.OwnerID = new SelectList(db.Owners, "OwnerID", "OwnerName", parkingSlot.OwnerID);
            return(View(parkingSlot));
        }
예제 #27
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ParkingSlot = await _context.ParkingSlot.FirstOrDefaultAsync(m => m.ParkingID == id);

            if (ParkingSlot == null)
            {
                return(NotFound());
            }
            return(Page());
        }
예제 #28
0
        public void CountMc2McTest()
        {
            //Setup
            string parkingPlace;

            parkingPlace = "poi987:abc124";
            int expectedCount = 2;
            int actualCount;

            //Act
            actualCount = ParkingSlot.CountMc(parkingPlace);

            //Verify
            Assert.AreEqual(expectedCount, actualCount);
        }
예제 #29
0
 private void AddParkingSlot()
 {
     for (int slotNumber = 1; slotNumber <= NumberOfSlots; slotNumber++)
     {
         var parkingslot = new ParkingSlot(Apply);
         ApplyToEntity(parkingslot,
                       new Events.CreateParkingSlot
         {
             ParkingSlotId = Guid.NewGuid(),
             SlotNumber    = slotNumber,
             Id            = ParkingLotId
         });
         ParkingSlots.Add(parkingslot);
     }
 }
예제 #30
0
        public void FindSearchStringNoMatchingTwoMcTest()
        {
            // Setup
            string slot = "tre4321:abc123";

            string[] expected = null;

            string[] actual;

            //Act
            actual = ParkingSlot.SearchVehicle(slot, "zaa");

            //Verify
            MyAssert.AreEqual(expected, actual);
        }