Beispiel #1
0
        public ActionResult <ParkinglotDto> GetOneParkinglot(int id)
        {
            var oneParkinglot     = _parkinglotService.GetOneParkinglot(id);
            var oneParkinglotsDto = _parkinglotMapper.DomainToDto(oneParkinglot);

            return(Ok(oneParkinglotsDto));
        }
Beispiel #2
0
        public void GivenAnAllocationService_WhenStartAllocation_ThenANewLocationIsReturned()
        {
            //Given
            Allocation startAllocation = new Allocation()
            {
                MemberPersonId = 1, ParkinglotId = 1
            };
            Parkinglot parkinglot = new Parkinglot()
            {
                Id = 1
            };

            _parkinglotService.GetOneParkinglot(1).Returns(parkinglot);
            _personService.GetById(1).Returns(_testPerson);
            _parkinglotService.ReduceAvailableParkingSpots(parkinglot).Returns(true);
            _allocationRepository.SaveNewAllocation(startAllocation).Returns(startAllocation);
            var allocationService = new AllocationService(_allocationRepository, _parkinglotService, _personService);
            //When
            var returnAllocation = allocationService.StartAllocation(startAllocation, _testPerson.LicensePlate);

            //Then
            Assert.IsType <Allocation>(returnAllocation);
        }
Beispiel #3
0
        public Allocation StartAllocation(Allocation newAllocation, LicensePlate memberLicensePlate)
        {
            Parkinglot parkinglotToChange = _parkinglotService.GetOneParkinglot(newAllocation.ParkinglotId);
            Person     person             = GetPersonFromAllocation(newAllocation);

            if (person.LicensePlate.Equals(memberLicensePlate))
            {
                _parkinglotService.ReduceAvailableParkingSpots(parkinglotToChange);
            }
            if (!person.LicensePlate.Equals(memberLicensePlate))
            {
                throw new EntityNotValidException("Licenseplate", memberLicensePlate);
            }

            return(_allocationRepository.SaveNewAllocation(newAllocation));
        }
        public void GivenListParkinglotDto_WhenGetOnel_ThenReturnOKWithOne()
        {
            //Given

            Parkinglot parkinglot = new Parkinglot();

            _parkinglotService.GetOneParkinglot(1).Returns(parkinglot);
            _parkinglotMapper.DomainToDto(parkinglot).Returns(new ParkinglotDto());


            //When
            OkObjectResult ok = (OkObjectResult)_parkinglotController.GetOneParkinglot(1).Result;

            //then
            Assert.Equal(200, ok.StatusCode);
            Assert.IsType <ParkinglotDto>(ok.Value);
        }