public async Task Post_RotateReturnsSuccessAndCorrectContent(string url) { var client = _factory.CreateClient(); var vm = new RotateNodeViewModel(); vm.SigmaGraphJson = SigmaGraphFactory.GetValidSigmaGraphJson(); vm.NodeId = "1"; var json = JsonConvert.SerializeObject(vm); var content = new StringContent(json, Encoding.UTF8, "application/x-ww-form-urlencoded"); HttpResponseMessage response = await client.PostAsync(url, content); response.EnsureSuccessStatusCode(); Assert.Equal("text/html; charset=utf-8", response.Content.Headers.ContentType.ToString()); }
public IActionResult RotateLeft(RotateNodeViewModel rotateNodeViewModel) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } RedBlackTree tree = null; tree = treeToJsonConverter.JsonToTree(rotateNodeViewModel.SigmaGraphJson); var id = Int32.Parse(rotateNodeViewModel.NodeId); var nodeD = tree.FindNode(id); tree.RotateLeft(nodeD); if (nodeD == null) { return(StatusCode(500, "Failed to rotate the node")); } return(Content(treeToJsonConverter.ToSigmaJson(tree))); }