Skip to content

Commit

Permalink
Merge with feature_linq
Browse files Browse the repository at this point in the history
  • Loading branch information
meberl committed May 23, 2018
2 parents ad73db6 + 65367dd commit a8c4c42
Show file tree
Hide file tree
Showing 85 changed files with 47,442 additions and 40,333 deletions.
Binary file modified Dependencies/Net40/HtmlAgilityPack.dll
Binary file not shown.
Binary file modified Dependencies/Net40/VDS.Common.dll
Binary file not shown.
Binary file modified Dependencies/Net40/dotNetRDF.dll
Binary file not shown.
79,628 changes: 39,772 additions & 39,856 deletions Dependencies/Net40/dotNetRDF.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Trinity.Tests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<Graph Uri="http://www.w3.org/2002/07/owl#" />
<Graph Uri="http://xmlns.com/foaf/0.1/" />
<Graph Uri="http://www.semanticdesktop.org/ontologies/2007/03/22/nco#" />

</Graphs>
</RuleSet>
</RuleSets>
Expand Down
85 changes: 85 additions & 0 deletions Trinity.Tests/Linq/LinqInferencingTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// LICENSE:
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// AUTHORS:
//
// Moritz Eberl <[email protected]>
// Sebastian Faubel <[email protected]>
//
// Copyright (c) Semiodesk GmbH 2017

using NUnit.Framework;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;

namespace Semiodesk.Trinity.Test.Linq
{
[TestFixture]
public class LinqInferencingTest
{
protected IStore Store;

protected IModel Model;

[SetUp]
public void SetUp()
{
// DotNetRdf memory store.
//string connectionString = "provider=dotnetrdf";

// OpenLink Virtoso store.
string connectionString = string.Format("{0};rule=urn:semiodesk/test/ruleset", SetupClass.ConnectionString);

Store = StoreFactory.CreateStore(connectionString);
Store.InitializeFromConfiguration();

Model = Store.CreateModel(new Uri("http://test.com/test"));
Model.Clear();

Assert.IsTrue(Model.IsEmpty);

Document doc = Model.CreateResource<Document>();
doc.Title = "Hello World!";
doc.Commit();

Person p1 = Model.CreateResource<Person>();
p1.FirstName = "Peter";
p1.LastName = "Steel";
p1.Made.Add(doc);
p1.Commit();


Assert.IsFalse(Model.IsEmpty);
}

[Test]
public void TestInverse()
{
var maker = from document in Model.AsQueryable<Document>(true) where document.Maker.FirstName == "Peter" select document.Maker;
Assert.AreEqual(1, maker.ToList().Count);
}


}
}
119 changes: 119 additions & 0 deletions Trinity.Tests/Linq/LinqModelGroupTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// LICENSE:
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// AUTHORS:
//
// Moritz Eberl <[email protected]>
// Sebastian Faubel <[email protected]>
//
// Copyright (c) Semiodesk GmbH 2017

using NUnit.Framework;
using System;

namespace Semiodesk.Trinity.Test.Linq
{
[TestFixture]
public class LinqModelGroupTest : LinqTestBase
{
[SetUp]
public override void SetUp()
{
// DotNetRdf memory store.
//string connectionString = "provider=dotnetrdf";

// OpenLink Virtoso store.
string connectionString = string.Format("{0};rule=urn:semiodesk/test/ruleset", SetupClass.ConnectionString);

Store = StoreFactory.CreateStore(connectionString);

IModel model1 = Store.CreateModel(new Uri("http://test.com/test1"));
model1.Clear();

IModel model2 = Store.CreateModel(new Uri("http://test.com/test2"));
model2.Clear();

Assert.IsTrue(model1.IsEmpty);
Assert.IsTrue(model2.IsEmpty);

// Add an agent so we can check if types are correctly queried.
Agent a1 = model1.CreateResource<Agent>(ex.John);
a1.FirstName = "John";
a1.LastName = "Doe";
a1.Commit();

Group g1 = model1.CreateResource<Group>(ex.TheSpiders);
g1.Name = "The Spiders";
g1.Commit();

Group g2 = model2.CreateResource<Group>(ex.AlicaKeys);
g2.Name = "Alicia Keys";
g2.Commit();

Person p1 = model1.CreateResource<Person>(ex.Alice);
p1.FirstName = "Alice";
p1.LastName = "Cooper";
p1.Age = 69;
p1.Birthday = new DateTime(1948, 2, 4);
p1.Group = g1;
p1.Status = true;
p1.AccountBalance = 10000000.1f;
p1.Commit();

Person p2 = model1.CreateResource<Person>(ex.Bob);
p2.FirstName = "Bob";
p2.LastName = "Dylan";
p2.Age = 76;
//p2.Status = false;
p2.Birthday = new DateTime(1941, 5, 24);
p2.AccountBalance = 1000000.1f;
p2.Commit();

Person p3 = model2.CreateResource<Person>(ex.Eve);
p3.FirstName = "Eve";
p3.LastName = "Jeffers-Cooper";
p3.Birthday = new DateTime(1978, 11, 10);
p3.Age = 38;
p3.Group = g2;
p3.AccountBalance = 100000.0f;
p3.Commit();

p1.KnownPeople.Add(p2);
p1.Commit();

p2.KnownPeople.Add(p1);
p2.KnownPeople.Add(p2);
p2.Commit();

p3.Interests.Add(g2);
p3.Interests.Add(p3);
p3.Commit();

Image i1 = model1.CreateResource<Image>();
i1.DepictedAgent = p1;
i1.Commit();

Assert.IsFalse(model1.IsEmpty);
Assert.IsFalse(model2.IsEmpty);

Model = Store.CreateModelGroup(model1, model2);
}
}
}
117 changes: 117 additions & 0 deletions Trinity.Tests/Linq/LinqModelTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// LICENSE:
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// AUTHORS:
//
// Moritz Eberl <[email protected]>
// Sebastian Faubel <[email protected]>
//
// Copyright (c) Semiodesk GmbH 2017

using NUnit.Framework;
using System;
using System.IO;

namespace Semiodesk.Trinity.Test.Linq
{
[TestFixture]
public class LinqModelTest : LinqTestBase
{
public LinqModelTest() {}

[SetUp]
public override void SetUp()
{
// DotNetRdf memory store.
//string connectionString = "provider=dotnetrdf";

// OpenLink Virtoso store.
//string connectionString = string.Format("{0};rule=urn:semiodesk/test/ruleset", SetupClass.ConnectionString);

string connectionString = "provider=stardog;host=http://localhost:5820;uid=admin;pw=admin;sid=test";

Store = StoreFactory.CreateStore(connectionString);

Model = Store.CreateModel(ex.Namespace);
Model.Clear();

Assert.IsTrue(Model.IsEmpty);

// Add an agent so we can check if types are correctly queried.
Agent a1 = Model.CreateResource<Agent>(ex.John);
a1.FirstName = "John";
a1.LastName = "Doe";
a1.Commit();

Group g1 = Model.CreateResource<Group>(ex.TheSpiders);
g1.Name = "The Spiders";
g1.Commit();

Group g2 = Model.CreateResource<Group>(ex.AlicaKeys);
g2.Name = "Alicia Keys";
g2.Commit();

Person p1 = Model.CreateResource<Person>(ex.Alice);
p1.FirstName = "Alice";
p1.LastName = "Cooper";
p1.Age = 69;
p1.Birthday = new DateTime(1948, 2, 4);
p1.Group = g1;
p1.Status = true;
p1.AccountBalance = 10000000.1f;
p1.Commit();

Person p2 = Model.CreateResource<Person>(ex.Bob);
p2.FirstName = "Bob";
p2.LastName = "Dylan";
p2.Age = 76;
//p2.Status = false;
p2.Birthday = new DateTime(1941, 5, 24);
p2.AccountBalance = 1000000.1f;
p2.Commit();

Person p3 = Model.CreateResource<Person>(ex.Eve);
p3.FirstName = "Eve";
p3.LastName = "Jeffers-Cooper";
p3.Birthday = new DateTime(1978, 11, 10);
p3.Age = 38;
p3.Group = g2;
p3.AccountBalance = 100000.0f;
p3.Commit();

p1.KnownPeople.Add(p2);
p1.Commit();

p2.KnownPeople.Add(p1);
p2.KnownPeople.Add(p2);
p2.Commit();

p3.Interests.Add(g2);
p3.Interests.Add(p3);
p3.Commit();

Image i1 = Model.CreateResource<Image>();
i1.DepictedAgent = p1;
i1.Commit();

Assert.IsFalse(Model.IsEmpty);
}
}
}
Loading

0 comments on commit a8c4c42

Please sign in to comment.