Exemple #1
0
        public void SerializeAndReadBack()
        {
            var registry = new DependencyFingerprintProtocolRegistry();

            registry.Register <FSRepositoryFingerprintProtocol>();

            var ser = new BinarySerializer(registry);
            var dep = new FSRepositoryReferenceDependencies(kernel.Get <IFSRepositoryFingerprintFactory>(), repository.Object, Path.Combine("test", "x"));
            var fp1 = dep.Fingerprint;

            byte[] data;
            using (var ms = new MemoryStream())
            {
                fp1.Save(ser, ms);
                data = ms.ToArray();
            }

            FSRepositoryFingerprint fp2;

            using (var ms = new MemoryStream(data))
            {
                fp2 = new FSRepositoryFingerprint(ser, ms);
            }

            fp1.Should().Be(fp2);
        }
Exemple #2
0
        public void CreatesSameFingerprintForSameState()
        {
            var dep = new FSRepositoryReferenceDependencies(kernel.Get <IFSRepositoryFingerprintFactory>(), repository.Object, "test\\x");
            var fp1 = dep.CreateFingerprint();
            var fp2 = dep.CreateFingerprint();

            fp1.Should().Be(fp2);
            fp2.Should().Be(fp1);
        }
Exemple #3
0
        public void ConvertToProtocolAndBack()
        {
            var dep = new FSRepositoryReferenceDependencies(kernel.Get <IFSRepositoryFingerprintFactory>(), repository.Object, Path.Combine("test", "x"));
            var fp1 = dep.Fingerprint;

            var proto = fp1.Protocol;
            var fp2   = proto.CreateFingerprint();

            fp1.Should().Be(fp2);
        }
Exemple #4
0
        public void CreatesSameFingerprintForSameState()
        {
            var dep1 = new FSRepositoryReferenceDependencies(kernel.Get <IFSRepositoryFingerprintFactory>(), repository.Object, Path.Combine("test", "x"));
            var dep2 = new FSRepositoryReferenceDependencies(kernel.Get <IFSRepositoryFingerprintFactory>(), repository.Object, Path.Combine("test", "x"));
            var fp1  = dep1.Fingerprint;
            var fp2  = dep2.Fingerprint;

            fp1.Should().Be(fp2);
            fp2.Should().Be(fp1);
        }
Exemple #5
0
        public void ChangingTheSourceChangesTheFingerprint()
        {
            var dep = new FSRepositoryReferenceDependencies(kernel.Get <IFSRepositoryFingerprintFactory>(), repository.Object, "test\\x");
            var fp1 = dep.CreateFingerprint();

            depRoot.SetFileSize("x", 200);

            var fp2 = dep.CreateFingerprint();

            depRoot.SetFileSize("x", 11); // default
            depRoot.SetDate("x", DateTime.Now);

            var fp3 = dep.CreateFingerprint();

            fp1.Should().NotBe(fp2);
            fp1.Should().NotBe(fp3);
            fp2.Should().NotBe(fp3);
        }
Exemple #6
0
        public void SerializeAndReadBack()
        {
            var ser = new BinarySerializer();
            var dep = new FSRepositoryReferenceDependencies(kernel.Get <IFSRepositoryFingerprintFactory>(), repository.Object, "test\\x");
            var fp1 = dep.CreateFingerprint();

            byte[] data;
            using (var ms = new MemoryStream())
            {
                fp1.Save(ser, ms);
                data = ms.ToArray();
            }

            FSRepositoryFingerprint fp2;

            using (var ms = new MemoryStream(data))
            {
                fp2 = new FSRepositoryFingerprint(ser, ms);
            }

            fp1.Should().Be(fp2);
        }