Esempio n. 1
0
        public void Deletion_of_an_existing_bucket_should_remove_existing_bucket_entry(string bucketId = null)
        {
            $"And a bucket id {BucketId}"
            .x(() => bucketId = BucketId);

            $"And an existing bucket entry with bucket id {BucketId} in reliable dictionary {S3BucketsKey}"
            .x(async() =>
            {
                var dictionary =
                    await _stateManager.GetOrAddAsync <IReliableDictionary <string, Bucket> >(S3BucketsKey);
                using (var tx = _stateManager.CreateTransaction())
                {
                    var bucket = new Bucket {
                        Id = bucketId, CreationDate = DateTime.UtcNow
                    };
                    await dictionary.AddAsync(tx, bucketId, bucket);
                    await tx.CommitAsync();
                }
            });

            $"When DeleteBucketAsync() will be called with bucket id = {BucketId}"
            .x(async() => await _storage.DeleteBucketAsync(bucketId));

            $"Then the reliable dictionary {S3BucketsKey} does not contain an entry with these bucket id"
            .x(async() =>
            {
                var dictionary = await _stateManager.TryGetAsync <IReliableDictionary <string, Bucket> >(S3BucketsKey);
                using (var tx = _stateManager.CreateTransaction())
                {
                    var exists = await dictionary.Value.ContainsKeyAsync(tx, bucketId);
                    Assert.False(exists);
                }
            });
        }
        public async Task <IActionResult> Delete(string bucket, CancellationToken cancellationToken)
        {
            await _storage.DeleteBucketAsync(bucket, cancellationToken);

            return(NoContent());
        }