예제 #1
0
        public void TestDelete()
        {
            car.Manufacturer = "VW";
            car.Model        = "Fusca";
            car.PhotoUrl     = string.Empty;

            carBusiness.Insert(car);
            carBusiness.Delete(car.Id);

            Assert.IsNull(carBusiness.Find(car.Id));
        }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (dataGridView.SelectedRows.Count > 0)
     {
         var         car         = dataGridView.SelectedRows[0].Cells;
         var         carId       = int.Parse(car[0].Value.ToString());
         CarBusiness carBusiness = new CarBusiness();
         carBusiness.Delete(carId);
         PopulateDataGridViewDefault();
         ResetSelect();
     }
 }
예제 #3
0
        public void DeleteFail()
        {
            var carRepository = new Mock <ICarRepository>();

            carRepository.Setup(x => x.Delete(It.IsAny <CarEntity>())).Returns(false);
            carRepository.Setup(x => x.GetAll()).Returns(GetCars());
            var carBusiness = new CarBusiness(carRepository.Object);

            var result = carBusiness.Delete(Guid.NewGuid());

            Assert.False(result);
        }