예제 #1
0
 public void Given_id_exist_should_delete_node_ok()
 {
     var nodeManager = new NodeManager("./root");
     dynamic node = new Node("mmm", _nodeMetadata);
     node.标题 = "标题";
     node.内容 = new MsDoc { Content = "内容" };
     nodeManager.AddNode(node);
     Directory.Exists("./root/mmm").Should().BeTrue();
     nodeManager.DeleteNode(node);
     Directory.Exists("./root/mmm").Should().BeFalse();
 }
예제 #2
0
 public void Given_id_not_exist_should_getbyid_method_ok()
 {
     var nodeManager = new NodeManager("./root");
     var node = nodeManager.GetNodeById("1");
     node.Id.Should().Be("1");
     node.Metadata.Name.Should().Be("题目");
     node.Metadata.Properties.Count().Should().Be(5);
     node.Metadata.Properties.ToArray().ElementAt(0).Name.Should().Be("题面");
     node.Metadata.Properties.ToArray().ElementAt(4).Name.Should().Be("难度");
     dynamic x = node.Properties.ElementAt(0).Value;
     (x.Content as string).Should().Be("这是题面");
     node.Properties.ElementAt(4).Value.Should().Be(3);
     node.Properties.ElementAt(3).Value.Should().Be("这是题目注释的内容。");
 }
예제 #3
0
 public void Given_id_exist_should_update_node_ok()
 {
     var nodeManager = new NodeManager("./root");
     dynamic node = new Node("xxx", _nodeMetadata);
     node.标题 = "标题";
     node.内容 = new MsDoc { Content = "内容" };
     nodeManager.AddNode(node);
     Directory.Exists("./root/xxx").Should().BeTrue();
     node.标题 = "update标题";
     node.内容 = new MsDoc{Content = "update"}; 
     nodeManager.UpdateNode(node);
     Directory.Exists("./root/xxx").Should().BeTrue();
     var fs = new FileStream("./root/xxx/内容.xml", FileMode.Open, FileAccess.Read);
     var sr = new StreamReader(fs);
     var s = sr.ReadToEnd();
     s.Should().Be("update");
     fs.Close(); sr.Close();
     nodeManager.DeleteNode(node);
 }