public LoadMD5 ( ) : System.Threading.Tasks.Task | ||
Résultat | System.Threading.Tasks.Task |
/// <summary> /// Store Items /// </summary> /// <param name="items">Items</param> public virtual async Task Store(IEnumerable <IStorageItem> items) { foreach (var item in items) { var path = item.RelativePath.Replace("\\", "/"); var exists = await this.container.Exists(path); if (exists) { await item.LoadMD5(); var existing = new BlobItem(container, path); await existing.LoadMD5(); if (item.MD5 == existing.MD5) { Trace.TraceInformation("Synchronization avoided: '{0}'.", item.Path); continue; } if (this.createSnapshot) { await this.container.Snapshot(path); } } await item.LoadMD5(); await item.Load(); Trace.TraceInformation("Uploading to blob: '{0}'.", path); await this.container.Save(path, item.Data, item.ContentType); if (0 < this.cacheControlDuration) { await this.container.SetCacheControl(path, this.cacheControlDuration); } } }
public async Task LoadMD5() { var random = new Random(); var bytes = new byte[64]; random.NextBytes(bytes); var p = new BlobProperties() { ContentType = Guid.NewGuid().ToString(), ContentMD5 = Guid.NewGuid().ToString(), }; var container = Substitute.For<IContainer>(); container.Properties("file.txt").Returns(Task.FromResult(p)); var bi = new BlobItem(container, "/file.txt"); await bi.LoadMD5(); Assert.AreEqual(p.ContentType, bi.ContentType); Assert.AreEqual(p.ContentMD5, bi.MD5); container.Received().Properties("file.txt"); }