public async Task TestCreateValidModelShouldReturnTrue() { var model = new NodeCreatePostModel() { Name = "Sofia" }; var result = await controller.Create(model); var jsonResult = result as JsonResult; var node = jsonResult?.Value as Node; Assert.IsNotNull(node); Assert.AreEqual(1, node.Id); Assert.AreEqual("Sofia", node.Name); }
public async Task TestCreateServerExceptionShouldReturnErrorMessage() { var result = await controller.Create(new NodeCreatePostModel() { Name = "Sofia" }); var badRequestResult = result as BadRequestObjectResult; Assert.IsNotNull(badRequestResult); Assert.AreEqual(400, badRequestResult.StatusCode); Assert.AreEqual("Something happened when creating new settlement", badRequestResult.Value as string); }