public void Test_Async_State() { var node = new TreeNode { Id = "1", Text = "a" }; _result = new TreeResult(new[] { node }, true); Assert.AreEqual("[{\"id\":\"1\",\"text\":\"a\",\"state\":\"closed\"}]", _result.ToString()); }
public void Test_2Node_Children() { var node = new TreeNode { Id = "1", Text = "a", Level = 1 }; var node2 = new TreeNode { Id = "2", ParentId = "1", Text = "b", Level = 2 }; _result = new TreeResult(new[] { node, node2 }); var expected = new Str(); expected.Add("[{\"id\":\"1\",\"text\":\"a\","); expected.Add("\"children\":[{\"id\":\"2\",\"ParentId\":\"1\",\"text\":\"b\"}]"); expected.Add("}]"); Assert.AreEqual(expected.ToString(), _result.ToString()); }
public void Test_3Node_Children() { var node = new TreeNode { Id = "1" }; var node2 = new TreeNode { Id = "2", ParentId = "1" }; var node3 = new TreeNode { Id = "3", ParentId = "2" }; _result = new TreeResult(new[] { node2, node3, node }); var expected = new Str(); expected.Add("[{\"id\":\"1\",\"children\":["); expected.Add("{\"id\":\"2\",\"ParentId\":\"1\",\"children\":["); expected.Add("{\"id\":\"3\",\"ParentId\":\"2\"}]"); expected.Add("}]}]"); Assert.AreEqual(expected.ToString(), _result.ToString()); }
public void Test_2Node() { var node = new TreeNode { Id = "1", Text = "a" }; var node2 = new TreeNode { Id = "2", Text = "b" }; _result = new TreeResult(new[] { node, node2 }); Assert.AreEqual("[{\"id\":\"1\",\"text\":\"a\"},{\"id\":\"2\",\"text\":\"b\"}]", _result.ToString()); }
public void Test_1Node() { var node = new TreeNode { Id = "1", Text = "a", Attributes = new { url = "b" } }; _result = new TreeResult(new[] { node }); Assert.AreEqual("[{\"id\":\"1\",\"text\":\"a\",\"attributes\":{\"url\":\"b\"}}]", _result.ToString()); }
public void TestNull() { _result = new TreeResult(null); Assert.AreEqual("[]", _result.ToString()); }