コード例 #1
0
        public void DeleteTruck_Fail()
        {
            var controller = new TruckController(repo);
            var truck      = new TruckViewModel
            {
                Chassis      = "ASDFASDFASDFASDFA",
                BuildingYear = 2020,
                ModelYear    = 2021
            };

            var        data   = controller.Delete(truck);
            ViewResult result = data as ViewResult;

            Assert.AreEqual("Delete", result.ViewName);
        }
コード例 #2
0
        public async Task DeleteTruck()
        {
            var mockServices  = new Mock <ITruckService>();
            var modelServices = new Mock <IModelService>();
            var unitOfWork    = new Mock <IUnitOfWork>();

            Guid idTruck = Guid.NewGuid();

            mockServices.Setup(x => x.DeleteTruck(idTruck)).Returns(Task.CompletedTask);

            var controller = new TruckController(unitOfWork.Object, mockServices.Object, modelServices.Object);

            var result = await controller.Delete(idTruck);

            var viewResult = Assert.IsType <PartialViewResult>(result);

            Assert.IsAssignableFrom <PartialViewResult>(viewResult);
        }
コード例 #3
0
        public void DeleteTruck_Ok()
        {
            var controller = new TruckController(repo);

            var            truck = repo.List().FirstOrDefault();
            TruckViewModel tvm   = new TruckViewModel
            {
                Chassis      = truck.Chassis,
                ModelYear    = truck.ModelYear,
                BuildingYear = truck.BuildingYear
            };

            var data = controller.Delete(tvm);
            RedirectToActionResult result = data as RedirectToActionResult;

            Assert.AreEqual("Index", result.ActionName);

            Assert.IsNull(repo.GetSingle(truck.Chassis));
        }