Пример #1
0
        public void TripleTest(string oldName, string newName)
        {
            using (var old = GetTestDataStream(oldName))
                using (var old2 = GetTestDataStream(oldName))
                    using (var @new = GetTestDataStream(newName))
                        using (var actual = new MemoryStream())
                        {
                            var builder = new SignatureBuilder();
                            var sigJob  = new SignatureJob(old, builder);
                            sigJob.Run();

                            old.Seek(0, SeekOrigin.Begin);

                            using (var delta = new MemoryStream())
                            {
                                var deltaEmitter = new DeltaEmitter(delta);
                                var deltaJob     = new DeltaJob(builder.GetSignature(), @new, deltaEmitter);
                                deltaJob.Run();

                                delta.Seek(0, SeekOrigin.Begin);

                                var patchJob = new DeltaReadJob(delta, new PatchProcessor(old2, actual));
                                patchJob.Run();
                            }

                            actual.Seek(0, SeekOrigin.Begin);
                            @new.Seek(0, SeekOrigin.Begin);

                            Assert.AreEqual(StreamToArray(@new), StreamToArray(actual));
                        }
        }
Пример #2
0
        private string GetHumanReadableDelta(string oldFile, string newFile)
        {
            using (var oldStream = GetTestDataStream(oldFile))
                using (var newStream = GetTestDataStream(newFile))
                {
                    var builder = new SignatureBuilder();
                    var sigJob  = new SignatureJob(oldStream, builder);
                    sigJob.Run();

                    oldStream.Seek(0, SeekOrigin.Begin);

                    var writer   = new HumanReadableDeltaWriter();
                    var deltaJob = new DeltaJob(builder.GetSignature(), newStream, writer);
                    deltaJob.Run();

                    return(writer.ToString());
                }
        }
Пример #3
0
        public void SameBlockTest()
        {
            var r = new Random(1337);
            var b = new byte[2048];

            r.NextBytes(b);

            using (var ms = new MemoryStream())
            {
                ms.Write(b, 0, b.Length);
                ms.Write(b, 0, b.Length);
                ms.Seek(0, SeekOrigin.Begin);

                var builder      = new SignatureBuilder();
                var signatureJob = new SignatureJob(ms, builder);
                signatureJob.Run();

                var sig = builder.GetSignature();
            }
        }