Exemple #1
0
        public async Task TestUpdateValidModelShouldReturnTrue()
        {
            var model = new NodeUpdatePostModel()
            {
                Id   = 1,
                Name = "Sofia"
            };

            var result = await controller.Update(model);

            var jsonResult = result as JsonResult;

            var updated = jsonResult?.Value as bool?;

            Assert.IsTrue(updated);
        }
        public async Task TestUpdateServerExceptionShouldReturnErrorMessage()
        {
            var result = await controller.Update(new NodeUpdatePostModel { Id = 1, Name = "Sofia" });

            var badRequestResult = result as BadRequestObjectResult;

            Assert.IsNotNull(badRequestResult);
            Assert.AreEqual(400, badRequestResult.StatusCode);
            Assert.AreEqual("Something happened when updating settlement", badRequestResult.Value as string);
        }