protected virtual async Task ValidateExists(GoogleCloudStorageUtils utils, string name, bool testMeta = false) { var obj = await utils.GetAsync(BucketName, name); Assert.NotNull(obj); Assert.Equal(BucketName, obj !.BucketName); Assert.Equal(name, obj.Name); Assert.Equal(ObjectContentType, obj.ContentType); Assert.Equal(ObjectCacheControl, obj.CacheControl); Assert.Equal(_imageData.Length, (long)obj.Size !.Value); using var buffer = new MemoryStream(); await utils.DownloadAsync(BucketName, name, buffer); Assert.True(_imageData.SequenceEqual(buffer.ToArray())); if (testMeta) { var guid = Guid.NewGuid().ToString(); var user = "******"; var obj1 = await utils.PathAsync(BucketName, name, new GoogleObjectPatchData { Acl = new List <GoogleAccessControlEntry> { new GoogleAccessControlEntry { Role = "READER", Entity = user } }, Metadata = new Dictionary <string, string> { { "guid", guid } } }, true); Assert.NotNull(obj1); Assert.NotNull(obj1 !.Acl); Assert.Contains(obj1.Acl, e => e.Role == "READER" && e.Entity == user); Assert.NotNull(obj1.Metadata); Assert.Contains(obj1.Metadata, kv => kv.Key == "guid" && kv.Value == guid); } }
protected virtual async Task ValidateDoesNotExist(GoogleCloudStorageUtils utils, string name) { var obj = await utils.GetAsync(BucketName, name); Assert.Null(obj); }