public void TestInsert() { car.Manufacturer = "Ferrari"; car.Model = "F50"; car.PhotoUrl = string.Empty; carBusiness.Insert(car); Assert.IsTrue(car.Id > 0); }
public void InsertFail() { var carRepository = new Mock <ICarRepository>(); var carEntity = new CarEntity { Brand = "Teste", Model = "Teste", Year = "Teste" }; carRepository.Setup(x => x.Insert(It.IsAny <CarEntity>())).Returns(carEntity); var carBusiness = new CarBusiness(carRepository.Object); var result = carBusiness.Insert(carEntity); Assert.False(result.Id != 0); }
public void InsertSucess() { var carRepository = new Mock <ICarRepository>(); var carEntity = new CarEntity { Brand = "Teste", Model = "Teste", Year = "Teste" }; carRepository.Setup(x => x.Insert(It.IsAny <CarEntity>())).Returns(carEntity); var carBusiness = new CarBusiness(carRepository.Object); var result = carBusiness.Insert(carEntity); Assert.True(result.UniqueKey != Guid.Empty); }
public IHttpActionResult Post([FromBody] Car car) { try { using (var c = new CarBusiness()) { if (c.Insert(car)) { return(Ok()); } return(NotFound()); } } catch (Exception ex) { return(BadRequest($"{ex}")); } }