public void CreateChild() { Console.WriteLine("Test adding a child element."); AFElement parent = new AFElement(); parent.Name = "Parent Element"; parent.Description = "Parent Desciption"; _db.CreateElement(parent); parent = AFElement.Find(_conn, parent.Name); Assert.IsNotNull(parent.ID); Assert.IsNotNull(parent.Path); AFElement child = new AFElement(); child.Name = "Child Element"; child.Description = "Child Description"; parent.Elements.Add(child); child = AFElement.FindByPath(_conn, child.Path); Assert.IsNotNull(child.Name); Assert.IsNotNull(child.ID); Assert.IsNotNull(child.Path); Assert.IsNotNull(child.Description); Assert.Equals(child.Parent.ID, parent.ID); parent = AFElement.FindByPath(_conn, parent.Path); //Assert.(parent.Elements.Count, 1); AFElement refChild = parent.Elements[0]; Console.WriteLine("Test that original child and referenced child are identical."); Assert.Equals(child.Name, refChild.Name); Assert.Equals(child.Path, refChild.Path); parent.Delete(); Assert.IsTrue(parent.IsDeleted); parent.CheckIn(); Assert.IsNull(AFElement.Find(_conn, parent.ID), "Assert that parent no longer exists"); Assert.IsNull(AFElement.Find(_conn, child.ID), "Assert that child no longer exists."); }
public void CreateElement() { AFElement element = GenerateElement(); Console.WriteLine("Test element creation."); Assert.IsTrue(_db.CreateElement(element), "Assert creation passed"); //Check that the the element can be found through the AFDB Assert.IsNotNull(_db.Elements[element.Name], "Check AFDB element collection for new element."); Assert.IsNotNull(AFElement.Find(_conn, element.WebID)); Assert.IsNotNull(AFElement.FindByPath(_conn, element.Path)); //Assert.IsNotNull(AFElement.FindByTemplate()); //Assert.IsNotNull(AFElement.FindByCategory(_conn, element.Categories.First())); //TODO: There should be more tests for finding the element element.Delete(); Assert.IsTrue(element.IsDeleted); element.CheckIn(); Assert.IsNull(AFElement.Find(_conn, element.WebID)); }