コード例 #1
0
        public async Task TestVehicleControllerShouldWork()
        {
            CreateVehicleCommand createVehicleCommand = new CreateVehicleCommand()
            {
                Id      = Guid.NewGuid(),
                Vehicle = "Ford",
                Body    = "Normal",
                Color   = "Blue"
            };

            _service.Setup(x => x.Build(createVehicleCommand));

            await _controller.CreateVehicle(createVehicleCommand);

            _service.Verify(x => x.Build(It.Is <CreateVehicleCommand>(command => command.Id == createVehicleCommand.Id)));
        }
コード例 #2
0
        public void CreateVehicle_WhenValidVehicle()
        {
            // Arrange
            var vehicle = new VehicleCreateDto
            {
                Year  = 2015,
                Make  = "Honda",
                Model = "Accord"
            };

            mockRepository.Setup(x => x.CreateVehicle(It.IsAny <VehicleCreateDto>()))
            .Returns(1);

            //Act
            var result        = _vehicleController.CreateVehicle(vehicle);
            var contentResult = (result as OkNegotiatedContentResult <string>)?.Content;

            //Assert
            Assert.AreEqual("Vehicle details added successfully", contentResult);
        }
コード例 #3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var t  = new Vehicle();
            var tc = new VehicleController();

            if (VehicleId > 0)
            {
                t                      = tc.GetVehicle(VehicleId, ModuleId);
                t.VehicleName          = txtName.Text.Trim();
                t.VehicleDescription   = txtDescription.Text.Trim();
                t.LastModifiedByUserId = UserId;
                t.LastModifiedOnDate   = DateTime.Now;
                t.VehicleOwnerUserId   = Convert.ToInt32(ddlVehicleOwnerUserId.SelectedValue);
            }
            else
            {
                t = new Vehicle()
                {
                    VehicleOwnerUserId = Convert.ToInt32(ddlVehicleOwnerUserId.SelectedValue),
                    CreatedByUserId    = UserId,
                    CreatedOnDate      = DateTime.Now,
                    VehicleName        = txtName.Text.Trim(),
                    VehicleDescription = txtDescription.Text.Trim(),
                };
            }

            t.LastModifiedOnDate   = DateTime.Now;
            t.LastModifiedByUserId = UserId;
            t.ModuleId             = ModuleId;

            if (t.VehicleId > 0)
            {
                tc.UpdateVehicle(t);
            }
            else
            {
                tc.CreateVehicle(t);
            }
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
        }