public async Task ParkingLotShouldBeAdded()
        {
            await RunWithinTransactionAndRollBack(async (client) =>
            {
                var parkingLotDto = new CreateNewParkingLotDto
                {
                    Name                = "PL3",
                    DivisionId          = 1,
                    BuildingTypeId      = BuildingTypes.Aboveground,
                    Capacity            = 500,
                    PricePerHour        = 15.55m,
                    ContactName         = "Test Test",
                    ContactMobilePhone  = "123456789",
                    ContactEmail        = "*****@*****.**",
                    ContactStreet       = "Streety",
                    ContactStreetNumber = "55",
                    ContactPostalCode   = "1000",
                    ContactPostalName   = "Brussels"
                };

                var payload = Serialize(parkingLotDto);
                var parkingLotAddResponse = await client.PostAsync("api/parkinglots", payload);
                var parkingLot            = await DeserializeAsAsync <ParkingLotDto>(parkingLotAddResponse.Content);

                Assert.AreEqual(parkingLotDto.Name, parkingLot.Name);
                Assert.AreEqual(parkingLotDto.Capacity, parkingLot.Capacity);
                Assert.AreEqual(parkingLotDto.BuildingTypeId, parkingLot.BuildingType.Id);
                Assert.AreEqual(parkingLotDto.ContactMobilePhone, parkingLot.Contact.MobilePhone);
                Assert.AreEqual(parkingLotDto.ContactStreet, parkingLot.Contact.Address.Street);
                Assert.AreNotEqual(default(int), parkingLot.Id);
            });
        }
Beispiel #2
0
        public async Task <ActionResult <ParkingLotDto> > CreateNewParkingLot(CreateNewParkingLotDto createNewParkingLotDto)
        {
            var parkingLot = this.mapper.MapTo <ParkingLot, CreateNewParkingLotDto>(createNewParkingLotDto);

            var newParkingLot = await this.service.CreateNewParkingLot(parkingLot);

            var parkingLotDto = this.mapper.MapTo <ParkingLotDto, ParkingLot>(newParkingLot);

            return(Ok(parkingLotDto));
        }
Beispiel #3
0
        public async Task ParkingLotShouldBeCreated()
        {
            using (var context = await NewParkSharkInMemoryTestContext())
            {
                var parkingLotService    = new ParkingLotService(context.ParkSharkDbContext);
                var parkingLotController = new ParkingLotsController(context.Mapper, parkingLotService);

                var parkingLotDto = new CreateNewParkingLotDto
                {
                    Name                = "PL2",
                    DivisionId          = 1,
                    BuildingTypeId      = BuildingTypes.Underground,
                    Capacity            = 500,
                    PricePerHour        = 15.55m,
                    ContactName         = "Maarten Merken",
                    ContactMobilePhone  = "00486743685",
                    ContactEmail        = "*****@*****.**",
                    ContactStreet       = "Aardeweg",
                    ContactStreetNumber = "39",
                    ContactPostalCode   = "3582",
                    ContactPostalName   = "Koersel"
                };

                var newParkingLot  = GetResult <ParkingLotDto>(await parkingLotController.CreateNewParkingLot(parkingLotDto));
                var parkingLotInDb = await context.ParkSharkDbContext.ParkingLots.FindAsync(newParkingLot.Id);

                var contactInDb = await context.ParkSharkDbContext.Contacts.FindAsync(newParkingLot.Contact.Id);

                var buildingTypeInDb = await context.ParkSharkDbContext.Set <BuildingType>().FindAsync(newParkingLot.BuildingType.Id);

                Assert.AreEqual(parkingLotInDb.Capacity, parkingLotDto.Capacity);
                Assert.AreEqual(buildingTypeInDb.Name, nameof(BuildingTypes.Underground));
                Assert.AreEqual(contactInDb.Email, contactInDb.Email);
                Assert.AreEqual(contactInDb.Address.Street, contactInDb.Address.Street);
            }
        }