public void TestDerivedConstructorTypeNameValue() { Composite.resetObjectId(); DerivedComposite com1 = new DerivedComposite("Book", "C# Programming", "Chapter 1"); Assert.IsTrue(com1.Type == "Book" && com1.Name == "C# Programming" && com1.Value == "Chapter 1"); }
public void TestDerivedCompositeConstructor() { Composite.resetObjectId(); Composite com = new DerivedComposite(); Assert.IsTrue(com.ObjectID == 1); Assert.IsTrue(com.Type == "DerivedComposite"); Assert.IsTrue(String.IsNullOrEmpty(com.Name)); Assert.IsTrue(String.IsNullOrEmpty(com.Value)); Assert.IsNotNull(com.Parents); Assert.IsNotNull(com.Children); }
public void TestTypeAssignedByTypeNameConstructor() { Composite parent = new Composite("Parent", "Father"); DerivedComposite child = new DerivedComposite("Child", "Son"); Assert.IsTrue(parent.Type == "Parent"); Assert.IsTrue(parent.GetType().Name == "Composite"); Assert.IsTrue(child.Type == "Child"); Assert.IsFalse(child.Type == "child"); Assert.IsTrue(child.GetType().Name == "DerivedComposite"); }
public void TestTypeAssignedByTypeConstructor() { Composite parent = new Composite("Parent"); DerivedComposite son = new DerivedComposite("Son"); Assert.IsTrue(parent.Type == "Parent"); Assert.IsTrue(parent.GetType().Name == "Composite"); Assert.IsTrue(son.Type == "Son"); Assert.IsTrue(son.GetType().Name == "DerivedComposite"); }
public void TestTypeAssignedByEmptyConstructor() { Composite com1 = new Composite(); DerivedComposite com2 = new DerivedComposite(); Assert.IsTrue(com1.Type == "Composite"); Assert.IsTrue(com1.GetType().Name == "Composite"); Assert.IsTrue(com2.Type == "DerivedComposite"); Assert.IsTrue(com2.GetType().Name == "DerivedComposite"); }
public void TestConstructorType() { Composite.resetObjectId(); Composite com1 = new Composite("DerivedComposite"); DerivedComposite com2 = new DerivedComposite(); Assert.IsTrue(com1.Type == "DerivedComposite" && com2.Type == "DerivedComposite"); Assert.IsTrue(String.IsNullOrEmpty(com1.Name) && String.IsNullOrEmpty(com2.Name)); Assert.IsTrue(String.IsNullOrEmpty(com1.Value) && String.IsNullOrEmpty(com2.Value)); Assert.IsNotNull(com1.Parents); Assert.IsNotNull(com2.Parents); Assert.IsNotNull(com1.Children); Assert.IsNotNull(com2.Children); }
public void TestAddChild() { Composite grandFather = new Composite(); Composite grandMother = new Composite(); Composite father = new Composite(); Composite mother = new Composite(); Composite son = new Composite(); Composite daughter = new Composite(); DerivedComposite stepDaughter = new DerivedComposite(); grandFather.addChild(father); grandMother.addChild(mother); father.addChild(son); father.addChild(daughter); father.addChild(stepDaughter); mother.addChild(son); mother.addChild(daughter); Assert.IsTrue(grandFather.Children.Count == 1); Assert.IsTrue(grandMother.Children.Count == 1); Assert.IsTrue(father.Children.Count == 3); Assert.IsTrue(mother.Children.Count == 2); Assert.IsTrue(son.Parents.Count == 2); Assert.IsTrue(daughter.Parents.Count == 2); Assert.IsTrue(stepDaughter.Parents.Count == 1); Assert.IsTrue(son.Children.Count == 0); Assert.IsTrue(daughter.Children.Count == 0); Assert.IsTrue(stepDaughter.Children.Count == 0); }