Esempio n. 1
0
        public async Task AllocationShouldFail_Validations()
        {
            using (var context = await NewParkSharkInMemoryTestContext())
            {
                var parkingLotService = new ParkingLotService(context.ParkSharkDbContext);
                var memberService     = new MemberService(context.ParkSharkDbContext);
                var allocationService =
                    new AllocationService(context.ParkSharkDbContext, memberService, parkingLotService);

                var now         = DateTime.Now;
                var allocation1 = await allocationService.CreateAllocation(new Allocation(1, 1, new LicensePlate("VXK014", "BE"), now));

                var allocation2 = await allocationService.CreateAllocation(new Allocation(1, 1, new LicensePlate("VXK014", "BE"), now));

                await Assert.ThrowsExceptionAsync <ValidationException <Allocation> >(async() => await allocationService.CreateAllocation(new Allocation(1, 1, new LicensePlate("VXK914", "BE"), now)));

                await Assert.ThrowsExceptionAsync <AllocationException>(async() => await allocationService.CreateAllocation(new Allocation(1, 1, new LicensePlate("VXK014", "BE"), now)));
            }
        }
Esempio n. 2
0
        public async Task AllocationShouldBeStopped_Fails_On_Member()
        {
            using (var context = await NewParkSharkInMemoryTestContext())
            {
                var parkingLotService = new ParkingLotService(context.ParkSharkDbContext);
                var memberService     = new MemberService(context.ParkSharkDbContext);
                var allocationService =
                    new AllocationService(context.ParkSharkDbContext, memberService, parkingLotService);

                var now        = DateTime.Now;
                var allocation = await allocationService.CreateAllocation(new Allocation(1, 1, new LicensePlate("VXK014", "BE"), now));

                await Assert.ThrowsExceptionAsync <AllocationException>(async() => await allocationService.StopAllocation(allocation.Id, 3));
            }
        }
Esempio n. 3
0
        public async Task AllocationShouldBeCreated_Active()
        {
            using (var context = await NewParkSharkInMemoryTestContext())
            {
                var parkingLotService = new ParkingLotService(context.ParkSharkDbContext);
                var memberService     = new MemberService(context.ParkSharkDbContext);
                var allocationService =
                    new AllocationService(context.ParkSharkDbContext, memberService, parkingLotService);

                var now        = DateTime.Now;
                var allocation = await allocationService.CreateAllocation(new Allocation(1, 1, new LicensePlate("VXK014", "BE"), now));

                var allocationInDb = await context.ParkSharkDbContext.Allocations.FindAsync(allocation.Id);

                Assert.AreEqual(AllocationStatus.Active, allocation.Status);
                Assert.AreEqual(AllocationStatus.Active, allocationInDb.Status);
            }
        }