コード例 #1
0
        public void HashingTwoTriplesInDifferentOrder()
        {
            var loggerMock     = new Mock <ILogger <CircleDotHashingService> >();
            var hashCalculator = new Sha256HashCalculator();
            var triples        = new HashSet <Triple>
            {
                new Triple(
                    new Iri("http://ontologies.makolab.com/gc/"),
                    new Iri("http://ontologies.makolab.com/gc/name"),
                    new Literal("Ontology1")),
                new Triple(
                    new Iri("http://ontologies.makolab.com/gc/"),
                    new Iri("http://ontologies.makolab.com/gc/name"),
                    new Literal("Ontology2"))
            };
            var hashingService = new CircleDotHashingService(loggerMock.Object, hashCalculator);
            var hashTriples1   = hashingService.CalculateHash(triples);

            triples = new HashSet <Triple>
            {
                new Triple(
                    new Iri("http://ontologies.makolab.com/gc/"),
                    new Iri("http://ontologies.makolab.com/gc/name"),
                    new Literal("Ontology2")),
                new Triple(
                    new Iri("http://ontologies.makolab.com/gc/"),
                    new Iri("http://ontologies.makolab.com/gc/name"),
                    new Literal("Ontology1"))
            };
            var hashTriples2 = hashingService.CalculateHash(triples);

            Assert.AreEqual(hashTriples1, hashTriples2);
        }
コード例 #2
0
        public void HashingTriple()
        {
            var loggerMock1    = new Mock <ILogger <CircleDotHashingService> >();
            var loggerMock2    = new Mock <ILogger <InterwovenHashingService> >();
            var hashCalculator = new Sha256HashCalculator();
            var triples        = new HashSet <Triple>
            {
                new Triple(
                    new Iri("http://ontologies.makolab.com/gc/"),
                    new Iri("http://ontologies.makolab.com/gc/name"),
                    new Literal("Ontology"))
            };
            var hashingService    = new CircleDotHashingService(loggerMock1.Object, hashCalculator);
            var interwovenService = new InterwovenHashingService(loggerMock2.Object, hashCalculator);
            var hashTriple        = hashingService.CalculateHash(triples);
            var interwovenHash    = interwovenService.CalculateHash(triples);

            Assert.AreEqual("9ca7f0185c00422b045dc8256a4872ef713ac57b059f49d1ad78808d4aca3c6a", hashTriple);
            Assert.AreEqual("9ca7f0185c00422b045dc8256a4872ef713ac57b059f49d1ad78808d4aca3c6a", interwovenHash);
        }