public async Task Delete_ShouldReturnOkIfDeleteSuccess()
        {
            // Arrange
            Service service = GetService();

            unitOfWorkMock.Setup(x => x.ServiceRepository.FindAsync(service.Id)).ReturnsAsync(service);
            unitOfWorkMock.Setup(x => x.CompleteAsync()).ReturnsAsync(1);

            // Act
            IHttpActionResult result = await controller.Delete(service.Id);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(OkResult));
        }
Ejemplo n.º 2
0
        public void TestRemove()
        {
            //Arrange
            ServiceContext c          = new ServiceContext();
            var            fakeRepo   = new FakeServicesRepository();
            var            controller = new ServicesController(fakeRepo, c);
            var            Service    = new ServiceModel()
            {
                ServiceID          = 0,
                ServiceName        = "SomeJob",
                ServiceDescription = "FAKE REPO TEST",
                ServiceEstimated   = "more for testing the repo fake",
                ServicePrice       = 80,
                User = new User()
                {
                    UserId = "1", UserName = "******", UserLast = "Fake2"
                },
            };

            //Act
            controller.Edit(Service);   // adds
            controller.Delete(Service); // and deletes

            // Assert Checking that story was added.

            Assert.Empty(fakeRepo.service);
        }
Ejemplo n.º 3
0
        public async void Delete_ReturnNotFound(int serviceID)
        {
            var controller = new ServicesController(Context, UserManager);

            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = PrestadorLog
            };
            var result = await controller.Delete(serviceID);

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

            Assert.Equal("/Views/Shared/NotFound.cshtml", viewResult.ViewName);
        }
Ejemplo n.º 4
0
        public async void Delete_ReturnViewResult(int serviceID)
        {
            var controller = new ServicesController(Context, UserManager);

            controller.ControllerContext.HttpContext = new DefaultHttpContext {
                User = PrestadorLog
            };
            var result = await controller.Delete(serviceID);

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <Service>(viewResult.ViewData.Model);

            Assert.NotNull(model);
            Assert.Equal(serviceID, model.ServiceID);
        }
        public async Task Delete_ReturnsNotContent_GivenTrue()
        {
            // Arrange
            var mockRepo = new Mock <IServiceService <Service> >();
            var dbMock   = GetBool(true);

            mockRepo.Setup(x => x.Delete(It.IsAny <int>()))
            .Returns(dbMock).Verifiable();

            var controller = new ServicesController(mockRepo.Object);

            // Act
            var result = await controller.Delete(1);

            // Assert
            mockRepo.VerifyAll();
            Assert.IsType <NoContentResult>(result);
        }
        public void Should_delete_service_on_delete_when_given_valid_vehicle_id()
        {
            //Arrange
            var _serviceRepo = new Mock <IRepository <ServiceModel> >();
            var _vehicleRepo = new Mock <IRepository <VehicleModel> >();

            var id = Guid.NewGuid();

            _serviceRepo.Setup(setup => setup.Read()).Returns(new System.Collections.Generic.List <ServiceModel>()
            {
                new ServiceModel()
                {
                    Id = id
                }
            });

            _controller = new ServicesController(_serviceRepo.Object, new ServicesValidation(), _vehicleRepo.Object);

            //Act
            var result = JsonConvert.DeserializeObject <ResultModel>(_controller.Delete(id.ToString()));

            //Assert
            _serviceRepo.Verify(mock => mock.Remove(It.IsAny <ServiceModel>()));
        }