private CloudEventStore GetEventStoreClient()
        {
            var blobClient = new CloudEventBlobClient(StorageAccount)
            {
                Configuration = { ContainerName = GetContainerName() }
            };
            var tableClient = new CloudEventTableClient(StorageAccount)
            {
                Configuration = { TableName = GetTableName() }
            };

            return(new CloudEventStore(blobClient, tableClient));
        }
        public async Task CloudEventBlobClient_GetLogSegmentedAsync_Test()
        {
            var containerName = GetContainerName();

            var client = new CloudEventBlobClient(StorageAccount);

            client.Configuration.ContainerName = containerName;
            await client.AppendAsync(new MemoryStream(new byte[] { 2, 3, 5, 7, 11 }));

            var result = await client.FetchAsync(new[] {
                new CloudEventLogPositionLength(0, 0, 1),
                new CloudEventLogPositionLength(0, 1, 1),
                new CloudEventLogPositionLength(0, 2, 1),
                new CloudEventLogPositionLength(0, 3, 1),
                new CloudEventLogPositionLength(0, 4, 1),
            });

            Assert.AreEqual(2, result[0].Data.GetItem(0));
            Assert.AreEqual(3, result[1].Data.GetItem(0));
            Assert.AreEqual(5, result[2].Data.GetItem(0));
            Assert.AreEqual(7, result[3].Data.GetItem(0));
            Assert.AreEqual(11, result[4].Data.GetItem(0));
        }
Exemplo n.º 3
0
        public CloudEventStore Create(string collectionName = "default")
        {
            if (StorageAccount == null)
            {
                throw new InvalidOperationException("storage account has not been set");
            }

            if (string.IsNullOrEmpty(collectionName))
            {
                throw new ArgumentException("collection name is null or empty", nameof(collectionName));
            }

            var blobClient = new CloudEventBlobClient(StorageAccount);

            blobClient.Configuration.ContainerName = "event-log" + "-" + collectionName;

            var tableClient = new CloudEventTableClient(StorageAccount);

            tableClient.Configuration.TableName = "EventStore" + char.ToUpperInvariant(collectionName[0]) + collectionName.Substring(1).ToLowerInvariant();

            var client = new CloudEventStore(blobClient, tableClient);

            return(client);
        }
        public async Task CloudEventBlobClient_AppendAsync_Test()
        {
            var containerName = GetContainerName();

            var client = new CloudEventBlobClient(StorageAccount);

            client.Configuration.ContainerName = containerName;
            await client.AppendAsync(new MemoryStream(new byte[] { 2 }));

            var client2 = new CloudEventBlobClient(StorageAccount);

            client2.Configuration.ContainerName = containerName;
            await client2.AppendAsync(new MemoryStream(new byte[] { 3 }));

            var client3 = new CloudEventBlobClient(StorageAccount);

            client3.Configuration.ContainerName = containerName;
            client3.Configuration.MaxBlockCount = 2;
            await client3.AppendAsync(new MemoryStream(new byte[] { 5 }));

            await client3.AppendAsync(new MemoryStream(new byte[] { 7 }));

            await client3.AppendAsync(new MemoryStream(new byte[] { 11 }));
        }