public void FikaControllerPostshouldReturnCreatedAtRouteNegotiatedContentResultOnSuccesfulPost() { Fika fika = new Fika(); fika.Date = new DateTime(); fika.Pastry = "NewPastry"; _service.Setup(s => s.AddFika(fika)).Returns(fika); FikaController controller = new FikaController(_service.Object); CreatedAtRouteNegotiatedContentResult<Fika> result = controller.Post(fika) as CreatedAtRouteNegotiatedContentResult<Fika>; Assert.AreEqual(fika, result.Content); }
public void FikaControllerPostShouldInvokeCallToServiceAddFika() { Fika fika = new Fika(); FikaController controller = new FikaController(_service.Object); controller.Post(fika); _service.Verify(s => s.AddFika(fika), Times.Once); }
public void FikaControllerPostShouldReturnBadRequestWhenModelStateIsNotValid() { Fika fika = new Fika(); FikaController controller = new FikaController(_service.Object); controller.ModelState.AddModelError("", "an error"); IHttpActionResult result = controller.Post(fika); Assert.IsInstanceOfType(result, typeof(BadRequestResult)); }