Esempio n. 1
0
        public void TestInsert()
        {
            car.Manufacturer = "Ferrari";
            car.Model        = "F50";
            car.PhotoUrl     = string.Empty;

            carBusiness.Insert(car);

            Assert.IsTrue(car.Id > 0);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 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}"));
     }
 }