コード例 #1
0
 public IHttpActionResult Create(ProductView product)
 {
     try
     {
         _productLibrary.Create(product);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message + ex.InnerException?.Message + ex.InnerException?.StackTrace));
     }
 }
コード例 #2
0
        public void Create()
        {
            var countShouldBe = _products.Count + 1;

            var product = new Product()
            {
                Id = Guid.NewGuid(), Name = "Nokia", Description = "Old school", Price = new decimal(200), DeliveryPrice = new decimal(0.00)
            };

            _productLibrary.Create(MapProductToProductView(product));
            var countIs = _products.Count;

            Assert.AreEqual(countIs, countShouldBe);
        }