public void CanRead_DetailCollection(IEnumerable values) { XmlableItem item = CreateOneItem <XmlableItem>(1, "item", null); DetailCollection dc = item.GetDetailCollection("Details", true); foreach (object detail in values) { dc.Add(detail); } ContentItem readItem = Mangle(item); DetailCollection readCollection = readItem.GetDetailCollection("Details", false); Assert.IsNotNull(readCollection); foreach (object detail in values) { if (detail is string) { EnumerableAssert.Contains(readCollection, HttpUtility.HtmlEncode((string)detail)); } else { EnumerableAssert.Contains(readCollection, detail); } } }
public void WriteItem_WithDetailCollection(Array array, Type type) { XmlableItem item = CreateOneItem <XmlableItem>(1, "one", null); DetailCollection dc = item.GetDetailCollection("Collected", true); foreach (object o in array) { dc.Add(o); } XPathNavigator xpn = WriteToStreamAndNavigate(item); XPathNodeIterator nodes = xpn.Select("//item/detailCollections/collection[@name='Collected']/detail"); Assert.AreEqual(array.Length, nodes.Count); while (nodes.MoveNext()) { EnumerableAssert.Contains(array, Convert.ChangeType(nodes.Current.Value, type)); } }
public void CanRead_DetailCollection(Array details) { XmlableItem item = CreateOneItem <XmlableItem>(1, "item", null); DetailCollection dc = item.GetDetailCollection("Details", true); foreach (object detail in details) { dc.Add(detail); } ContentItem readItem = Mangle(item); DetailCollection readCollection = readItem.GetDetailCollection("Details", false); Assert.IsNotNull(readCollection); foreach (object detail in details) { EnumerableAssert.Contains(readCollection, detail); } }
public void WriteItem_WithLinkCollection() { XmlableItem item = CreateOneItem <XmlableItem>(1, "one", null); XmlableItem two = CreateOneItem <XmlableItem>(2, "two", null); XmlableItem three = CreateOneItem <XmlableItem>(3, "three", null); XmlableItem four = CreateOneItem <XmlableItem>(4, "four", null); DetailCollection dc = item.GetDetailCollection("Related", true); dc.Add(two); dc.Add(three); dc.Add(four); XPathNavigator xpn = WriteToStreamAndNavigate(item); XPathNodeIterator nodes = xpn.Select("//item/detailCollections/collection[@name='Related']/detail"); Assert.AreEqual(3, nodes.Count); nodes.MoveNext(); Assert.AreEqual("2", nodes.Current.Value); nodes.MoveNext(); Assert.AreEqual("3", nodes.Current.Value); nodes.MoveNext(); Assert.AreEqual("4", nodes.Current.Value); }