Пример #1
0
        public async Task makereservation_should_invoke_savechanges_on_dbcontext()
        {
            var command = new CreateCarReservation
            {
                City            = "TestCity",
                PostCode        = "57-400",
                Name            = "TestName",
                CarTypeId       = 0,
                PhoneNumber     = "55555555",
                ReservationDate = "2018-08-08",
                Street          = "TestStreet"
            };


            CarReservationEntity carReservation = new CarReservationEntity(command.CarTypeId, command.City
                                                                           , command.PostCode, command.Street, command.PhoneNumber, command.Name, command.GetReservationDate());
            var result = await carReservationProcess.MakeReservation(carReservation);

            mockcontext.Verify(x => x.SaveChangesAsync(), Times.Once);
            Assert.True(result.Success);
        }
Пример #2
0
        public async Task <ActionResult> CreateCarReservation(CreateCarReservation command)
        {
            CommandResult result;

            if (ModelState.IsValid)
            {
                result = await CommandDispatcher.DispatchAsync(command);

                if (!result.Success)
                {
                    ViewBag.CarTypeList = await QueryDispatcher.DispatchAll <CarTypeViewModel>();

                    ModelState.AddModelError("", $"{result.Message}");
                    return(View());
                }
                return(View("ReservationSuccess"));
            }
            else
            {
                ViewBag.CarTypeList = await QueryDispatcher.DispatchAll <CarTypeViewModel>();

                return(View(command));
            }
        }