public void Generate_check() { IList<SignatureInfo> sourceSignatureInfos; IList<SignatureInfo> seedSignatureInfos; using (var sourceSignatureRepository = CreateSignatureRepositoryFor("test")) using (var seedSignatureRepository = CreateSignatureRepositoryFor("test")) { using (var generator = new SigGenerator()) { seedSignatureInfos = generator.GenerateSignatures(GetSeedStream(), "test", seedSignatureRepository); } var sourceStream = GetSourceStream(); using (var generator = new SigGenerator()) { sourceSignatureInfos = generator.GenerateSignatures(sourceStream, "test", sourceSignatureRepository); } var sourceSize = sourceStream.Length; using (var tested = new NeedListGenerator(sourceSignatureRepository, seedSignatureRepository)) { var result = tested.CreateNeedsList(seedSignatureInfos.Last(), sourceSignatureInfos.Last()); Assert.NotNull(result); Assert.Equal(0, sourceSize - result.Sum(x => Convert.ToInt32(x.BlockLength))); } } }
public void ctor_and_dispose() { using (var signatureRepository = CreateSignatureRepositoryFor("test")) using (var tested = new NeedListGenerator(signatureRepository, signatureRepository)) { Assert.NotNull(tested); } }
private async Task SynchronizeAsync(string localSigName, string localSigSigName, string remoteSigName, string remoteSigSigName, CancellationToken token) { using (var needListGenerator = new NeedListGenerator(localSignatureRepository, remoteCacheSignatureRepository)) { var source = new RemoteSignaturePartialAccess(ravenFileSystemClient, remoteSigName); var seed = new SignaturePartialAccess(localSigName, localSignatureRepository); var needList = needListGenerator.CreateNeedsList(SignatureInfo.Parse(localSigSigName), SignatureInfo.Parse(remoteSigSigName), token); using (var output = remoteCacheSignatureRepository.CreateContent(remoteSigName)) { await NeedListParser.ParseAsync(source, seed, output, needList, token); } } }
public void Synchronize_file_with_different_beginning() { const int size = 5000; var differenceChunk = new MemoryStream(); var sw = new StreamWriter(differenceChunk); sw.Write("Coconut is Stupid"); sw.Flush(); var sourceContent = PrepareSourceStream(size); sourceContent.Position = 0; var seedContent = new CombinedStream(differenceChunk, sourceContent); using (var sourceSignatureRepository = CreateSignatureRepositoryFor("test2")) using (var seedSignatureRepository = CreateSignatureRepositoryFor("test1")) { IList<SignatureInfo> seedSignatureInfos; using (var generator = new SigGenerator()) { seedContent.Seek(0, SeekOrigin.Begin); seedSignatureInfos = generator.GenerateSignatures(seedContent, "test1", seedSignatureRepository); } IList<SignatureInfo> sourceSignatureInfos; using (var generator = new SigGenerator()) { sourceContent.Seek(0, SeekOrigin.Begin); sourceSignatureInfos = generator.GenerateSignatures(sourceContent, "test2", sourceSignatureRepository); } var sourceSize = sourceContent.Length; using (var tested = new NeedListGenerator(seedSignatureRepository, sourceSignatureRepository)) { var result = tested.CreateNeedsList(seedSignatureInfos.Last(), sourceSignatureInfos.Last()); Assert.NotNull(result); Assert.Equal(2, result.Count); Assert.Equal(0, sourceSize - result.Sum(x => Convert.ToInt32(x.BlockLength))); } } }
private async Task<SynchronizationReport> SynchronizeTo(string destinationServerUrl, ISignatureRepository localSignatureRepository, ISignatureRepository remoteSignatureRepository, SignatureManifest sourceSignatureManifest, SignatureManifest destinationSignatureManifest) { var seedSignatureInfo = SignatureInfo.Parse(destinationSignatureManifest.Signatures.Last().Name); var sourceSignatureInfo = SignatureInfo.Parse(sourceSignatureManifest.Signatures.Last().Name); using (var localFile = StorageStream.Reading(Storage, FileName)) { IList<RdcNeed> needList; using (var needListGenerator = new NeedListGenerator(remoteSignatureRepository, localSignatureRepository)) { needList = needListGenerator.CreateNeedsList(seedSignatureInfo, sourceSignatureInfo, Cts.Token); } return await PushByUsingMultipartRequest(destinationServerUrl, localFile, needList); } }