コード例 #1
0
        public void Throw_WhenPassedParameterIsNull()
        {
            //Arrange
            var brands        = new Mock <IEfGenericRepository <Brand> >();
            var brandsService = new BrandsService(brands.Object);

            //Act & Assert
            Assert.Throws <ArgumentNullException>(() => brandsService.Create(null));
        }
コード例 #2
0
 public ActionResult <Brand> Create([FromBody] Brand newBrand)
 {
     try
     {
         return(Ok(_ss.Create(newBrand)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #3
0
        public void InvokeRepositoryMethodAddOnce_WhenPassedParameterIsValid()
        {
            //Arrange
            var brands = new Mock <IEfGenericRepository <Brand> >();

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

            //Act
            brandsService.Create(brand);

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