public void Post_Valid_API() { //Arrange Type item = new Type() { Description = "test", Status = "test" }; //Act var actionResult = controllerAPI.Post(item); var createdResult = actionResult as CreatedAtRouteNegotiatedContentResult <Type>; //Assert Assert.IsNotNull(createdResult); Assert.AreEqual("DefaultApi", createdResult.RouteName); Assert.AreEqual(item, createdResult.Content); Assert.IsInstanceOfType(createdResult.Content, typeof(Type)); Assert.IsNotNull(createdResult.RouteValues["id"]); }
public void TypeControllerPostTest() { var topic = CreateContext(); var Logic = CreateLogic(); var Controller = new TypesController(Logic); var Type = new TypeEntity { Id = Guid.NewGuid(), Name = "First Type", Topic = topic, TopicId = topic.Id }; var result = Controller.Post(TypeDTO.ToModel(Type)); var createdResult = result as CreatedAtRouteResult; var model = createdResult.Value as TypeDTO; Assert.AreEqual(Type.Name, model.Name); }