Exemple #1
0
        public async Task WriteAndReadSnapshot(String fakeState, int eventsInSnapshot)
        {
            var log = new LoggerConfiguration().CreateLogger();
            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
            CloudTable          cloudTable          = cloudStorageAccount.CreateCloudTableClient().GetTableReference("unitTestTable");
            var blobClient = cloudStorageAccount.CreateCloudBlobClient();
            await cloudTable.DeleteIfExistsAsync();

            await cloudTable.CreateIfNotExistsAsync();

            var blobContainer = blobClient.GetContainerReference("testing");
            await blobContainer.DeleteIfExistsAsync();

            await blobContainer.CreateIfNotExistsAsync();

            await blobContainer.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Container });

            String    streamName = "teststream";
            Partition partition  = new Partition(cloudTable, streamName);
            Stream    stream     = new Stream(partition);

            EventTableStoreStream eventTableStoreStream = new EventTableStoreStream(partition, stream, streamName, SerializerSettings);
            SnapshotBlobStream    snapshotBlobStream    = new SnapshotBlobStream("snapshot.test", blobContainer, SerializerSettings, eventTableStoreStream);


            await snapshotBlobStream.WriteSnapshot(fakeState, eventsInSnapshot);

            var snapshotData = await snapshotBlobStream.ReadSnapshot();

            String readState = snapshotBlobStream.ReadSnapshotFromUri <String>(snapshotData.SnapshotUri);

            snapshotData.EventsInSNapshot.Should().Be(eventsInSnapshot);
            readState.Should().BeEquivalentTo(fakeState);
        }
Exemple #2
0
        public async Task WriteAndReadEvents(Event[] events)
        {
            var log = new LoggerConfiguration().CreateLogger();
            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
            CloudTable          cloudTable          = cloudStorageAccount.CreateCloudTableClient().GetTableReference("unitTestTable");
            await cloudTable.DeleteIfExistsAsync();

            await cloudTable.CreateIfNotExistsAsync();

            String                streamName            = "teststream";
            Partition             partition             = new Partition(cloudTable, streamName);
            Stream                stream                = new Stream(partition);
            EventTableStoreStream eventTableStoreStream = new EventTableStoreStream(partition, stream, "teststream", SerializerSettings);

            await eventTableStoreStream.StoreEvents(events);

            var eventsReturned = await eventTableStoreStream.ReadEvents(x =>
            {
            }, 0);

            int ver = eventTableStoreStream.Version;

            ver.Should().Be(events.Length);
        }