Example #1
0
 public void TestAdd()
 {
     sut.Add(new Topping()
     {
         Name = "TestName"
     });
     Assert.AreEqual(1, toppingRepositoryMock.Invocations.Count);
 }
Example #2
0
        public IActionResult Post([FromBody] Topping topping)
        {
            if (string.IsNullOrEmpty(topping.Name))
            {
                return(new ObjectResult(new { Status = 400, Value = "Topping name can't be empty" }));
            }

            try
            {
                toppingService.Add(topping);
                return(new ObjectResult(new { Status = 200, Value = string.Format("Topping {0} created", topping.Name) }));
            }
            catch (Exception exception)
            {
                return(new ObjectResult(new { Status = 500, Value = exception.Message }));
            }
        }