/// <summary> /// Override of the Equals method for Results /// </summary> /// <param name="obj"></param> /// <returns></returns> /// <remarks>Used implicitly in applying Distinct and Reduced modifiers to the Result Set</remarks> public override bool Equals(object obj) { if (obj == null) { return(false); } else if (obj is SparqlResult) { SparqlResult other = (SparqlResult)obj; // Empty Results are only equal to Empty Results if (this._resultValues.Count == 0 && other._resultValues.Count == 0) { return(true); } if (this._resultValues.Count == 0 || other._resultValues.Count == 0) { return(false); } // For differing numbers of values we must contain all the same values for variables // bound in both or the variable missing from us must be bound to null in the other foreach (String v in other.Variables) { if (this._resultValues.ContainsKey(v)) { if (this._resultValues[v] == null && other[v] != null) { return(false); } else if (this._resultValues[v] == null && other[v] == null) { continue; } else if (!this._resultValues[v].Equals(other[v])) { return(false); } } else { if (other.HasBoundValue(v)) { return(false); } } } return(true); } else { return(false); } }
private static void Test(string query, string literal) { IGraph graph = new Graph(); graph.LoadFromString(TestData); IInMemoryQueryableStore store = new TripleStore(); store.Add(graph); IQueryableStorage storage = new InMemoryManager(store); using (SparqlResultSet resultSet = (SparqlResultSet)storage.Query(query)) { TestTools.ShowResults(resultSet); Assert.Equal(1, resultSet.Count); SparqlResult result = resultSet[0]; Assert.True(result.HasBoundValue("oo")); Assert.Equal(graph.CreateLiteralNode(literal), result["oo"]); } }