Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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));
        }
Ejemplo n.º 8
0
        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));
        }