public void Test_Container_AddTwoEqualNames_Exception() { IElement dir = ElementFactory.CreateDirectory("dir"); dir.AddChild(ElementFactory.CreateFile("file")); dir.AddChild(ElementFactory.CreateFile("file")); }
public void Test_Container_Creating() { IElement dir = ElementFactory.CreateDirectory("dir"); Assert.AreEqual(dir.Name, "dir"); Assert.AreEqual(dir.ChildrenCount, 0); }
public void Test_Container_AddNestedElement() { IElement root = ElementFactory.CreateRoot(); IElement directory = root.AddChild(ElementFactory.CreateDirectory("Dir")); directory.AddChild(ElementFactory.CreateFile("file1")); directory.AddChild(ElementFactory.CreateFile("file2")); IElement nestedDirectory = directory.AddChild(ElementFactory.CreateDirectory("nested")); nestedDirectory.AddChild(ElementFactory.CreateFile("file11")); nestedDirectory.AddChild(ElementFactory.CreateFile("file12")); nestedDirectory.AddChild(ElementFactory.CreateFile("file13")); nestedDirectory.AddChild(ElementFactory.CreateFile("file14")); Assert.AreEqual(root.ChildrenCount, 1); Assert.AreEqual(root["dir"].ChildrenCount, 3); Assert.AreEqual(root["dir"][0].Name, "file1"); Assert.AreEqual(root["dir"][1].Name, "file2"); Assert.AreEqual(root["dir"][2].Name, "nested"); Assert.AreEqual(root["dir"][2].ChildrenCount, 4); Assert.AreEqual(root["dir"]["nested"][0].Name, "file11"); Assert.AreEqual(root["dir"]["nested"][1].Name, "file12"); Assert.AreEqual(root["dir"]["nested"][2].Name, "file13"); Assert.AreEqual(root["dir"]["nested"][3].Name, "file14"); }
public void Test_Container_Path() { IElement file = ElementFactory.CreateRoot().AddChild(ElementFactory.CreateDirectory("dir1")).AddChild( ElementFactory.CreateDirectory("dir2")).AddChild(ElementFactory.CreateFile("file")); Assert.AreEqual(file.Path, @"C:\dir1\dir2\file"); }
public void Test_Container_RemoveChild() { IElement dir = ElementFactory.CreateDirectory("dir"); IElement file = dir.AddChild(ElementFactory.CreateFile("file")); Assert.AreEqual(dir.ChildrenCount, 1); dir.RemoveChild(file); Assert.AreEqual(dir.ChildrenCount, 0); }
public void Test_Container_CaseInsensitive() { IElement root = ElementFactory.CreateRoot(); root.AddChild(ElementFactory.CreateFile("aAa")); root.AddChild(ElementFactory.CreateDirectory("BbB")); root.AddChild(ElementFactory.CreateFile("cCc")); Assert.AreSame(root["aaa"], root["AaA"]); Assert.AreEqual(root["aaa"].Name, "aAa"); Assert.AreSame(root["bbb"], root["bBb"]); Assert.AreEqual(root["BBB"].Name, "BbB"); }
protected override void DoExecute() { FindParentElement(Operands[0]).AddChild(ElementFactory.CreateDirectory(Operands[0].NameOnly)); }