public Task CreateOrUpdateBlobAsync(string containerName, string blobName, byte[] blobContents)
 {
     // We invoke this Coyote API to explicitly insert a "scheduling point" during the test execution
     // where the Coyote scheduler should explore a potential interleaving with another concurrently
     // executing operation. As this is a write operation we invoke the 'Write' scheduling point with
     // the corresponding container name, which can help Coyote optimize exploration.
     SchedulingPoint.Write(containerName);
     this.Containers[containerName][blobName] = blobContents;
     return(Task.CompletedTask);
 }
 public Task CreateContainerIfNotExistsAsync(string containerName)
 {
     // We invoke this Coyote API to explicitly insert a "scheduling point" during the test execution
     // where the Coyote scheduler should explore a potential interleaving with another concurrently
     // executing operation. As this is a write operation we invoke the 'Write' scheduling point with
     // the corresponding container name, which can help Coyote optimize exploration.
     SchedulingPoint.Write(containerName);
     this.Containers.TryAdd(containerName, new Dictionary <string, byte[]>());
     return(Task.CompletedTask);
 }
        public Task <bool> DeleteContainerIfExistsAsync(string containerName)
        {
            // We invoke this Coyote API to explicitly insert a "scheduling point" during the test execution
            // where the Coyote scheduler should explore a potential interleaving with another concurrently
            // executing operation. As this is a write operation we invoke the 'Write' scheduling point with
            // the corresponding container name, which can help Coyote optimize exploration.
            SchedulingPoint.Write(containerName);
            bool result = this.Containers.Remove(containerName);

            return(Task.FromResult(result));
        }
Exemple #4
0
        public Task <ICosmosContainer> CreateContainerAsync(string containerName)
        {
            // We invoke this Coyote API to explicitly insert a "scheduling point" during the test execution
            // where the Coyote scheduler should explore a potential interleaving with another concurrently
            // executing operation. As this is a write operation we invoke the 'Write' scheduling point with
            // the corresponding container name, which can help Coyote optimize exploration.
            SchedulingPoint.Write(containerName);
            this.State.CreateContainer(containerName);
            ICosmosContainer container = new MockCosmosContainer(containerName, this.State);

            return(Task.FromResult(container));
        }
        public Task DeleteAllBlobsAsync(string containerName)
        {
            // We invoke this Coyote API to explicitly insert a "scheduling point" during the test execution
            // where the Coyote scheduler should explore a potential interleaving with another concurrently
            // executing operation. As this is a write operation we invoke the 'Write' scheduling point with
            // the corresponding container name, which can help Coyote optimize exploration.
            SchedulingPoint.Write(containerName);
            if (this.Containers.TryGetValue(containerName, out Dictionary <string, byte[]> container))
            {
                container.Clear();
            }

            return(Task.CompletedTask);
        }
        public Task DeleteItem(string partitionKey, string id)
        {
            // We invoke this Coyote API to explicitly insert a "scheduling point" during the test execution
            // where the Coyote scheduler should explore a potential interleaving with another concurrently
            // executing operation. As this is a write operation we invoke the 'Write' scheduling point with
            // the corresponding container name, which can help Coyote optimize exploration.
            SchedulingPoint.Write(this.ContainerName);
            if (this.EmitRandomizedFaults && this.Generator.NextBoolean())
            {
                throw new SimulatedDatabaseFaultException();
            }

            this.State.DeleteItem(this.ContainerName, partitionKey, id);
            return(Task.CompletedTask);
        }
        public Task <bool> DeleteBlobIfExistsAsync(string containerName, string blobName)
        {
            // We invoke this Coyote API to explicitly insert a "scheduling point" during the test execution
            // where the Coyote scheduler should explore a potential interleaving with another concurrently
            // executing operation. As this is a write operation we invoke the 'Write' scheduling point with
            // the corresponding container name, which can help Coyote optimize exploration.
            SchedulingPoint.Write(containerName);
            if (!this.Containers.TryGetValue(containerName, out Dictionary <string, byte[]> container))
            {
                return(Task.FromResult(false));
            }

            bool result = container.Remove(blobName);

            return(Task.FromResult(result));
        }
        public Task <T> UpsertItem <T>(T item)
            where T : DbItem
        {
            // We invoke this Coyote API to explicitly insert a "scheduling point" during the test execution
            // where the Coyote scheduler should explore a potential interleaving with another concurrently
            // executing operation. As this is a write operation we invoke the 'Write' scheduling point with
            // the corresponding container name, which can help Coyote optimize exploration.
            SchedulingPoint.Write(this.ContainerName);
            if (this.EmitRandomizedFaults && this.Generator.NextBoolean())
            {
                throw new SimulatedDatabaseFaultException();
            }

            var itemCopy = TestHelper.Clone(item);

            this.State.UpsertItem(this.ContainerName, itemCopy);
            return(Task.FromResult(itemCopy));
        }