public void Throw_WhenPassedParameterIsNull()
        {
            //Arrange
            var brands        = new Mock <IEfGenericRepository <Brand> >();
            var brandsService = new BrandsService(brands.Object);

            //Act & Assert
            Assert.Throws <ArgumentNullException>(() => brandsService.Delete(null));
        }
Пример #2
0
 public ActionResult <string> Delete(int id)
 {
     try
     {
         return(Ok(_ss.Delete(id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public void InvokeRepositoryMethodDeleteOnce_WhenPassedParameterIsValid()
        {
            //Arrange
            var brands = new Mock <IEfGenericRepository <Brand> >();

            brands.Setup(x => x.Delete(It.IsAny <Brand>())).Verifiable();
            var brandsService = new BrandsService(brands.Object);
            var brand         = DataHelper.GetBrand();

            //Act
            brandsService.Delete(brand);

            //Assert
            brands.Verify(x => x.Delete(It.IsAny <Brand>()), Times.Once);
        }