Ejemplo n.º 1
0
        public void Should_be_mergable_with_other()
        {
            // when
            var reconstruct = new GraphReconstruct(EntityId, GraphId, new EntityQuad[0]);
            var other       = new GraphReconstruct(EntityId, GraphId, new EntityQuad[0]);

            // then
            reconstruct.CanMergeWith(other).Should().BeTrue();
        }
Ejemplo n.º 2
0
        public void Should_be_mergable_with_update()
        {
            // when
            var reconstruct = new GraphReconstruct(EntityId, GraphId, new EntityQuad[0]);
            var update      = new GraphUpdate(EntityId, GraphId, new EntityQuad[0], new EntityQuad[0]);

            // then
            reconstruct.CanMergeWith(update).Should().BeTrue();
        }
Ejemplo n.º 3
0
        private IEnumerable <SparqlUpdateCommand> CreateReconstructCommand(GraphReconstruct change)
        {
            INodeFactory factory      = new NodeFactory();
            var          addedTriples = ConvertTriples(change.AddedQuads, factory).Replace("\\u", "\\\\u");

            var commandText    = string.Format(ReconstructCommandText, addedTriples);
            var deleteCommands = new SparqlParameterizedString(commandText);

            deleteCommands.SetUri("graph", change.Graph.Uri);
            deleteCommands.SetUri("metaGraph", MetaGraphUri);
            deleteCommands.SetUri("entity", change.Entity.Uri);

            return(GetParsedCommands(deleteCommands));
        }
Ejemplo n.º 4
0
        public void Merging_should_combine_recreate_graph_with_another_by_discarding_the_former()
        {
            // given
            var graphFirst  = new[] { AQuad };
            var graphSecond = new[] { CQuad, BQuad };
            var update      = new GraphReconstruct(EntityId, GraphId, graphFirst);
            var other       = new GraphReconstruct(EntityId, GraphId, graphSecond);

            // when
            var merged = (GraphReconstruct)update.MergeWith(other);

            // then
            merged.Should().Be(other);
        }
Ejemplo n.º 5
0
        public void Merging_should_combine_recreate_graph_with_update()
        {
            // given
            var newGraph     = new[] { AQuad, CQuad };
            var removedQuads = new[] { AQuad };
            var addedQuads   = new[] { CQuad, BQuad };
            var update       = new GraphReconstruct(EntityId, GraphId, newGraph);
            var other        = new GraphUpdate(EntityId, GraphId, removedQuads, addedQuads);

            // when
            var merged = (GraphReconstruct)update.MergeWith(other);

            // then
            merged.AddedQuads.Should().Contain((IEnumerable)addedQuads);
        }