Exemplo n.º 1
0
        public void CanDropAGraph()
        {
            using (var repoFixture = new RepositoryFixture("test-drop"))
            {
                repoFixture.Import("data\\test1.nq");
                var g          = new Graph();
                var testUri0   = g.CreateUriNode(new Uri("http://example.org/s/0"));
                var testUri1   = g.CreateUriNode(new Uri("http://example.org/s/1"));
                var testUri2   = g.CreateUriNode(new Uri("http://example.org/s/2"));
                var testUri3   = g.CreateUriNode(new Uri("http://example.org/s/3"));
                var testUri4   = g.CreateUriNode(new Uri("http://example.org/s/4"));
                var testUri190 = g.CreateUriNode(new Uri("http://example.org/s/190"));
                repoFixture.Store.GetTriplesForSubject(testUri0).Should().HaveCount(5);
                repoFixture.Store.GetTriplesForSubject(testUri1).Should().HaveCount(5);
                repoFixture.Store.GetTriplesForSubject(testUri2).Should().HaveCount(5);
                repoFixture.Store.GetTriplesForSubject(testUri3).Should().HaveCount(5);
                repoFixture.Store.GetTriplesForSubject(testUri4).Should().HaveCount(5);
                repoFixture.Store.GetTriplesForSubject(testUri190).Should().HaveCount(5);

                repoFixture.Store.DropGraph(new Uri("http://example.org/g/1"));
                repoFixture.Store.Flush();

                repoFixture.Store.GetTriplesForSubject(testUri0).Should().HaveCount(0);
                repoFixture.Store.GetTriplesForSubject(testUri1).Should().HaveCount(5);
                repoFixture.Store.GetTriplesForSubject(testUri2).Should().HaveCount(5);
                repoFixture.Store.GetTriplesForSubject(testUri3).Should().HaveCount(5);
                repoFixture.Store.GetTriplesForSubject(testUri4).Should().HaveCount(5);
                repoFixture.Store.GetTriplesForSubject(testUri190).Should().HaveCount(0);
            }
        }
Exemplo n.º 2
0
 public void ItReturnsAnEmptyEnumerationWhenTheSpecifiedObjectDoesNotExist()
 {
     using (var repoFixture = new RepositoryFixture("test-getbyinvalidobject"))
     {
         repoFixture.Import("data\\test1.nq");
         var target  = new Uri("http://example.org/s/0");
         var triples = repoFixture.Store.GetTriplesForObject(target).ToList();
         triples.Should().BeEmpty();
     }
 }
Exemplo n.º 3
0
 public void CanGetTriplesWithSpecificObject()
 {
     using (var repoFixture = new RepositoryFixture("test-getbyobject"))
     {
         repoFixture.Import("data\\test1.nq");
         var target  = new Uri("http://example.org/o/0");
         var triples = repoFixture.Store.GetTriplesForObject(target).ToList();
         triples.Count.Should().Be(5);
         triples.All(t => (t.Object as IUriNode)?.Uri.Equals(target) ?? false).Should().BeTrue();
     }
 }
Exemplo n.º 4
0
 public void CanEnumerateSubjects()
 {
     using (var repoFixture = new RepositoryFixture("test-enumerate"))
     {
         repoFixture.Import("data\\test1.nq");
         var testHandler = new TestTripleCollectionHandler(tc =>
         {
             tc.Count.Should().Be(5);
             tc.All(x => x.Subject.Equals(tc[0].Subject)).Should().BeTrue();
         });
         repoFixture.Store.EnumerateSubjects(testHandler);
         testHandler.TotalCount.Should().Be(200);
     }
 }
Exemplo n.º 5
0
 public void CreatesDirectoryMap()
 {
     using (var repoFixture = new RepositoryFixture("test-enumerate"))
     {
         repoFixture.Import("data\\test1.nq");
         var dirMapPath = Path.Combine(repoFixture.BaseDirectory.FullName, "dirmap.txt");
         Assert.True(File.Exists(dirMapPath));
         var dirMapLines = File.ReadAllLines(dirMapPath);
         Assert.Contains(dirMapLines, x => x.Equals("_s"));
         Assert.Contains(dirMapLines, x => x.Equals("_o"));
         Assert.Contains(dirMapLines, x => x.Equals("_p"));
         Assert.True(dirMapLines.All(x => x.StartsWith("_s") || x.StartsWith("_o") || x.StartsWith("_p")));
     }
 }
Exemplo n.º 6
0
 public void CanEnumerateObjectStatements()
 {
     using (var repoFixture = new RepositoryFixture("test-enumerate"))
     {
         repoFixture.Import("data\\test3.nq");
         var testHandler = new TestResourceStatementHandler((objectNode, subjectStatements, objectStatements) =>
         {
             subjectStatements.All(x => x.Subject.Equals(objectNode)).Should().BeTrue();
             objectStatements.All(x => x.Object.Equals(objectNode)).Should().BeTrue();
         });
         repoFixture.Store.EnumerateObjects(testHandler);
         testHandler.TotalSubjects.Should().Be(2);
         testHandler.TotalSubjectStatements.Should().Be(5);
         testHandler.TotalObjectStatements.Should().Be(7);
     }
 }
Exemplo n.º 7
0
 public void CanEnumerateSharedObjects()
 {
     using (var repoFixture = new RepositoryFixture("test-enumerate"))
     {
         repoFixture.Import("data\\test2a.nq");
         var testHandler = new TestTripleCollectionHandler(tc =>
         {
             tc.All(x => x.Object.Equals(tc[0].Object)).Should().BeTrue();
             var objectUri = (tc[0].Object as IUriNode)?.Uri?.ToString();
             objectUri.Should().NotBeNull();
             if (objectUri.Equals("http://example.org/o/0"))
             {
                 tc.Count.Should().Be(3);
             }
             if (objectUri.Equals("http://example.org/o/1"))
             {
                 tc.Count.Should().Be(2);
             }
         });
         repoFixture.Store.EnumerateObjects(testHandler);
         testHandler.TotalCount.Should().Be(2);
     }
 }