public MapperService() { Configuration = new MapperConfiguration(cfg => { IVehiculosService _vs = new VehiculosService(); //origen,destino cfg.CreateMap <Vehiculo, VehiculoDTO>().ForMember(dest => dest.Dni, opts => opts.MapFrom(src => src.ConductoresHabituales.FirstOrDefault().DNI)); cfg.CreateMap <VehiculoDTO, Vehiculo>(); cfg.CreateMap <Conductor, ConductorDTO>(); cfg.CreateMap <ConductorDTO, Conductor>(); cfg.CreateMap <Infraccion, InfraccionDTO>(); cfg.CreateMap <InfraccionDTO, Infraccion>(); cfg.CreateMap <InfraccionRegistrada, InfraccionRegistradaDTO>().ForMember(dest => dest.vehiculo, opts => opts.MapFrom(src => _vs.GetVehiculos((v) => v.Matricula == src.Matricula))); cfg.CreateMap <Marca, MarcaDTO>(); cfg.CreateMap <MarcaDTO, Marca>(); cfg.CreateMap <Modelo, ModeloDTO>(); cfg.CreateMap <ModeloDTO, Modelo>(); }); ServiceMapper = Configuration.CreateMapper(); }
public void ModificarVehiculo_No_Existente_TestMethod() { //Arrange IVehiculosService service = new VehiculosService(new UnitOfWork()); bool result; Vehiculo vehiculo = service.TraerVehiculo("0"); //Act result = service.ModificarVehiculo(vehiculo); //Assert Assert.AreEqual(false, result); }
public void CrearVehiculo_Fail_TestMethod() { //Arrange Vehiculo vehiculo = new Vehiculo(); IVehiculosService service = new VehiculosService(new UnitOfWork()); bool result; vehiculo.Placa = "WJY306"; vehiculo.Modelo = 2015; vehiculo.Imagen = null; //Act result = service.CrearNuevoVehiculo(vehiculo); //Assert Assert.AreEqual(false, result); }