public async Task AllocationShouldBeStopped()
        {
            await RunWithinTransactionAndRollBack(async (client) =>
            {
                var createAllocationDto = new CreateAllocationDto
                {
                    ParkingLotId        = 1,
                    LicensePlateNumber  = "VXK014",
                    MemberId            = 2,
                    LicensePlateCountry = "BE"
                };

                var payload = Serialize(createAllocationDto);
                var allocationAddResponse = await client.PostAsync("api/allocations", payload);
                var allocation            = await DeserializeAsAsync <AllocationDto>(allocationAddResponse.Content);

                var stopAllocationDto = new StopAllocationDto
                {
                    AllocationId = allocation.Id,
                    MemberId     = 2,
                };
                payload = Serialize(stopAllocationDto);
                var allocationStopResponse = await client.PutAsync("api/allocations", payload);
                allocation = await DeserializeAsAsync <AllocationDto>(allocationStopResponse.Content);

                Assert.AreEqual("Passive", allocation.Status);
            });
        }
示例#2
0
        public async Task <ActionResult <AllocationDto> > CreateAllocation(CreateAllocationDto createAllocation)
        {
            var allocation = this.mapper.MapTo <Allocation, CreateAllocationDto>(createAllocation);

            var newAllocation = await this.service.CreateAllocation(allocation);

            var dto = this.mapper.MapTo <AllocationDto, Allocation>(newAllocation);

            return(Ok(dto));
        }
        public async Task AllocationShouldBeCreated()
        {
            await RunWithinTransactionAndRollBack(async (client) =>
            {
                var createAllocationDto = new CreateAllocationDto
                {
                    ParkingLotId        = 1,
                    LicensePlateNumber  = "VXK014",
                    MemberId            = 2,
                    LicensePlateCountry = "BE"
                };

                var payload = Serialize(createAllocationDto);
                var allocationAddResponse = await client.PostAsync("api/allocations", payload);
                var allocation            = await DeserializeAsAsync <AllocationDto>(allocationAddResponse.Content);


                Assert.AreEqual(createAllocationDto.ParkingLotId, allocation.ParkingLot.Id);
                Assert.AreEqual(createAllocationDto.MemberId, allocation.Member.Id);
                Assert.AreEqual(createAllocationDto.LicensePlateNumber, allocation.LicensePlate.Number);
                Assert.AreEqual(createAllocationDto.LicensePlateCountry, allocation.LicensePlate.Country);
            });
        }