Example #1
0
        public void CreatePost()
        {
            var controller = new VehiclesController();

            var result = controller.Create(1);

            Assert.IsNotNull(result);
        }
        public async void TestVehicleCreateErrorView()
        {
            var obj = new VehiclesController();

            ViewResult result = await obj.Create(new Domain.Entities.Vehicle()
            {
                changeDate   = DateTime.Now,
                inputDate    = DateTime.Now,
                Manufacturer = "Ford"
            }) as ViewResult;

            Assert.IsNotNull(result);
        }
Example #3
0
        public async Task Post_NormalParameters_Sucess()
        {
            CreatingVehicleDto request = new CreatingVehicleDto("AA-12-BB", "A1B2C3D4E5F6G7H8I", "Miniautocarro", 1000);

            var mock = new Mock <IVehicleService>();

            mock.Setup(service => service.AddAsync(It.IsAny <VehicleDto>())).Returns(Task.FromResult(VehicleMapper.toDTO(request)));
            VehiclesController controller = new VehiclesController(mock.Object);

            var result = await controller.Create(request);

            mock.Verify(service => service.AddAsync(It.IsAny <VehicleDto>()), Times.AtLeastOnce());
            ActionResult <VehicleDto> VehicleDto = VehicleMapper.toDTO(request);

            Assert.IsInstanceOfType(result, typeof(ActionResult <VehicleDto>));
        }
Example #4
0
        public async Task Post_NormalParameters_Sucess()
        {
            CreatingVehicleDto creatingVehicleDto = new CreatingVehicleDto("AA-12-BB", "A1B2C3D4E5F6G7H8I", "Miniautocarro", 1000);

            VehicleDto VehicleDto     = VehicleMapper.toDTO(creatingVehicleDto);
            Vehicle    Vehicle        = VehicleMapper.toDomain(VehicleDto);
            var        mockRepository = new Mock <IVehicleRepository>();

            mockRepository.Setup(repository => repository.AddAsync(It.IsAny <Vehicle>())).Returns(Task.FromResult(Vehicle));

            var mockUnit = new Mock <IUnitOfWork>();

            VehicleService     VehicleService = new VehicleService(mockUnit.Object, mockRepository.Object);
            VehiclesController controller     = new VehiclesController(VehicleService);

            var result = await controller.Create(creatingVehicleDto);

            mockRepository.Verify(repository => repository.AddAsync(It.IsAny <Vehicle>()), Times.AtLeastOnce());
            mockUnit.Verify(unit => unit.CommitAsync(), Times.AtLeastOnce());
            Assert.IsInstanceOfType(result, typeof(ActionResult <VehicleDto>));
        }
        public void Create_DadoModel_DeveChamarCreateCommandUmaVez()
        {
            _controller.Create(It.IsAny <Vehicle>());

            _createCommandMock.Verify(query => query.Execute(It.IsAny <Vehicle>()), Times.Once);
        }