public async Task Then_AddJobCommand_is_handled(
            long accountId,
            JobRequest request,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] JobController controller)
        {
            var controllerResult = await controller.AddJob(request) as StatusCodeResult;

            mockMediator
            .Verify(mediator => mediator.Send(
                        It.Is <AddJobCommand>(c =>
                                              c.Type.Equals(request.Type) &&
                                              c.Data.Equals(request.Data)),
                        It.IsAny <CancellationToken>()));

            Assert.IsNotNull(controllerResult);
            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.NoContent);
        }
Exemplo n.º 2
0
        protected void AddJobButton_Click(object sender, EventArgs e)
        {
            MessageUserControl.TryRun(() =>
            {
                JobController control        = new JobController();
                JobPoco newJob               = new JobPoco();
                ServiceDetailPoco newService = new ServiceDetailPoco();
                int customerId               = int.Parse(CustomerDDL.SelectedValue);
                if (employeeId == null)
                {
                    throw new Exception("Please sign in as valid employee");
                }

                if (customerId == 0)
                {
                    throw new Exception("please select a valid Customer");
                }

                bool success = (decimal.TryParse(ShopRateTB.Text, out decimal shoprate));
                if (!success)
                {
                    throw new Exception("Must enter a valid shop rate value (default 80)");
                }
                if (string.IsNullOrWhiteSpace(VehicleTB.Text))
                {
                    throw new Exception("Please enter a vehical identifaction");
                }

                success = decimal.TryParse(HoursTB.Text, out decimal hours);
                if (success && hours > 0)
                {
                    newService.JobHours = hours;
                }
                else
                {
                    throw new Exception("Must enter a valid decimal greater than 0 for hours.");
                }
                newJob.EmployeeID            = employeeId;
                newJob.CustomerID            = customerId;
                newJob.JobDateIn             = DateTime.Today;
                newJob.StatusCode            = "I";
                newJob.ShopRate              = shoprate;
                newJob.VehicleIdentification = VehicleTB.Text;

                newService.Description = DescriptionTB.Text;
                newService.CouponID    = int.Parse(CouponDDL.SelectedValue);
                newService.Comments    = CommentsTB.Text;

                control.AddJob(newJob, newService);

                DescriptionTB.Text      = "";
                HoursTB.Text            = "";
                CouponDDL.SelectedIndex = 0;
                CommentsTB.Text         = "";

                NewJobButton.Visible       = true;
                NewJobCustomer.Visible     = false;
                currentJobListForm.Visible = true;
                NewJobForm.Visible         = false;
                currentJobForm.Visible     = false;
                AddServiceButton.Visible   = true;
                AddJobButton.Visible       = false;


                JobGridView.DataSource = control.ListCurrentJobs();
                JobGridView.DataBind();
            });
        }