public void XliffElement_AddChildElementsToList() { TestXliffElement element; List<ElementInfo> list; List<XliffElement> children; element = new TestXliffElement(); children = new List<XliffElement>(); Console.WriteLine("Test with null."); list = null; element.CallAddChildElementsToList(null, ref list); Assert.IsNull(list, "List is incorrect."); Console.WriteLine("Test with empty enumeration."); list = null; element.CallAddChildElementsToList(new XliffElement[] { }, ref list); Assert.IsNull(list, "List is incorrect."); Console.WriteLine("Test with invalid enumeration."); children.Add(new Target()); list = null; try { element.CallAddChildElementsToList(children, ref list); Assert.Fail("Expected KeyNotFoundException to be thrown."); } catch (KeyNotFoundException) { } Console.WriteLine("Test with valid enumeration."); children.Clear(); children.Add(new File()); children.Add(new File()); children.Add(new Source()); list = null; element.CallAddChildElementsToList(children, ref list); Assert.AreEqual(3, list.Count, "List count is incorrect."); Assert.AreEqual(ElementNames.File, list[0].LocalName, "LocalName[0] is incorrect."); Assert.AreEqual(ElementNames.File, list[1].LocalName, "LocalName[1] is incorrect."); Assert.AreEqual(ElementNames.Source, list[2].LocalName, "LocalName[2] is incorrect."); Assert.AreEqual(children[0], list[0].Element, "Element[0] is incorrect."); Assert.AreEqual(children[1], list[1].Element, "Element[1] is incorrect."); Assert.AreEqual(children[2], list[2].Element, "Element[2] is incorrect."); Console.WriteLine("Test with full list."); list = new List<ElementInfo>(); list.Add(new ElementInfo(new XmlNameInfo("name"), new TestXliffElement())); children.Clear(); children.Add(new File()); element.CallAddChildElementsToList(children, ref list); Assert.AreEqual(2, list.Count, "List count is incorrect."); Assert.AreEqual("name", list[0].LocalName, "LocalName[0] is incorrect."); Assert.AreEqual(ElementNames.File, list[1].LocalName, "Key[1] is incorrect."); Assert.AreEqual(children[0], list[1].Element, "Value[1] is incorrect."); }
public void XliffElement_AddChildElementsToList() { TestXliffElement element; List <ElementInfo> list; List <XliffElement> children; element = new TestXliffElement(); children = new List <XliffElement>(); Console.WriteLine("Test with null."); list = null; element.CallAddChildElementsToList(null, ref list); Assert.IsNull(list, "List is incorrect."); Console.WriteLine("Test with empty enumeration."); list = null; element.CallAddChildElementsToList(new XliffElement[] { }, ref list); Assert.IsNull(list, "List is incorrect."); Console.WriteLine("Test with invalid enumeration."); children.Add(new Target()); list = null; try { element.CallAddChildElementsToList(children, ref list); Assert.Fail("Expected KeyNotFoundException to be thrown."); } catch (KeyNotFoundException) { } Console.WriteLine("Test with valid enumeration."); children.Clear(); children.Add(new File()); children.Add(new File()); children.Add(new Source()); list = null; element.CallAddChildElementsToList(children, ref list); Assert.AreEqual(3, list.Count, "List count is incorrect."); Assert.AreEqual(ElementNames.File, list[0].LocalName, "LocalName[0] is incorrect."); Assert.AreEqual(ElementNames.File, list[1].LocalName, "LocalName[1] is incorrect."); Assert.AreEqual(ElementNames.Source, list[2].LocalName, "LocalName[2] is incorrect."); Assert.AreEqual(children[0], list[0].Element, "Element[0] is incorrect."); Assert.AreEqual(children[1], list[1].Element, "Element[1] is incorrect."); Assert.AreEqual(children[2], list[2].Element, "Element[2] is incorrect."); Console.WriteLine("Test with full list."); list = new List <ElementInfo>(); list.Add(new ElementInfo(new XmlNameInfo("name"), new TestXliffElement())); children.Clear(); children.Add(new File()); element.CallAddChildElementsToList(children, ref list); Assert.AreEqual(2, list.Count, "List count is incorrect."); Assert.AreEqual("name", list[0].LocalName, "LocalName[0] is incorrect."); Assert.AreEqual(ElementNames.File, list[1].LocalName, "Key[1] is incorrect."); Assert.AreEqual(children[0], list[1].Element, "Value[1] is incorrect."); }