public IEnumerable<IndexEntry> Index(Document document) { return IndexParser.GetEqExpressions(_indexText) .Select(eqExpression => document.FindValues(eqExpression.Item1.FullPath).Cast<Tuple<string,object>>().Select(t => t.Item1 + "=" + t.Item2)) .CartesianProduct() .Select(combination => new IndexEntry(combination)); }
public void GetDocumentListNamesTest() { var target = new Document(); const string name = "foo"; target.SetDocumentList(name, new List<Document>()); Assert.AreEqual(name, target.GetDocumentListNames().Single()); }
public void GetAttributeNamesTest() { var target = new Document(); const string name = "foo"; target.SetAttribute(name, ""); Assert.AreEqual(name, target.GetAttributeNames().Single()); }
public void FindValues_WithThreePartPath_ShouldReturnAttributeValue() { var target = new Document(); object expected = new Tuple<string,object>("foo/bar/quux","baz"); target.GetSubDocument("foo").GetSubDocument("bar").SetAttribute("quux", "baz"); var actual = target.FindValues("foo/bar/quux").Single(); Assert.AreEqual(expected, actual, "GetAttributeReturnedDifferentValueFromSet"); }
public void FindValues_WithTwoPartPath_ShouldReturnSubDocumentAttributeValue() { var target = new Document(); const string value = "bar"; object expected = new Tuple<string,object>("foo/foo","bar"); target.GetSubDocument("foo").SetAttribute("foo", value); var actual = target.FindValues("foo/foo").Single(); Assert.AreEqual(expected, actual, "GetAttributeReturnedDifferentValueFromSet"); }
public void FindValues_WithAttributeName_ShouldReturnAttributeValue() { var target = new Document(); const string name = "foo"; const string value = "bar"; object expected = new Tuple<string,object>(name,value); target.SetAttribute(name, value); var actual = target.FindValues(name).Single(); Assert.AreEqual(expected, actual, "GetAttributeReturnedDifferentValueFromSet"); }
public void GetDocumentListTest() { var target = new Document(); const string name = "foo"; var actual = target.GetDocumentList(name); Assert.IsNotNull(actual); Assert.AreEqual(0, actual.Count); }
public void GetAttribute_WhenNotSet_ShouldThrowIndexOutOfRangeException() { var target = new Document(); const string name = "foo"; target.GetAttribute(name); }
public void SetSubDocumentTest() { var target = new Document(); const string name = "foo"; var document = new Document(); target.SetSubDocument(name, document); Assert.AreEqual(document, target.GetSubDocument(name)); }
public void SetListTest() { var target = new Document(); const string name = "foo"; var list = new List<object>(); target.SetList(name, list); Assert.AreEqual(list, target.GetList(name)); }
public void SetAttributeTest() { var target = new Document(); const string name = "foo"; object value = "bar"; target.SetAttribute(name, value); Assert.AreEqual(value, target.GetAttribute(name)); }
public void GetSubDocumentTest() { var target = new Document(); const string name = "foo"; var actual = target.GetSubDocument(name); Assert.IsNotNull(actual); }
public void GetSetAttributeTest() { var target = new Document(); const string name = "foo"; object expected = "bar"; target.SetAttribute(name, expected); var actual = target.GetAttribute(name); Assert.AreEqual(expected, actual, "GetAttributeReturnedDifferentValueFromSet"); }
public void SetSubDocument(string name, Document document) { Data[name] = document; }