public void Should_store_data_as_serialized_body()
        {
            var message             = new CloudQueueMessage(@event);
            var transportExtensions = new TransportExtensions <AzureStorageQueueTransport>(new SettingsHolder());

            AzureStorageQueuesTransportExtensions.EnableSupportForEventGridEvents(transportExtensions);
            var wrapper = AzureStorageQueuesTransportExtensions.unwrapper(message);

            using (var stream = new MemoryStream(wrapper.Body))
                using (var streamReader = new StreamReader(stream))
                    using (var textReader = new JsonTextReader(streamReader))
                    {
                        var jsonSerializer = new JsonSerializer();
                        var body           = jsonSerializer.Deserialize <BlobCreated>(textReader);

                        Assert.Equal("PutBlob", body.Api);
                        Assert.Equal("BlockBlob", body.BlobType);
                        Assert.Equal("f15c08e0-b6a9-11e8-b16a-1d5a6655a317", body.ClientRequestId);
                        Assert.Equal("application/xml", body.ContentType);
                        Assert.Equal(1308, body.ContentLength);
                        Assert.Equal("https://eventgridtest.blob.core.windows.net/eventgrid-post/file.txt", body.Url);
                        Assert.Equal("0x8D5ED2CD5C5F045", body.ETag);
                        Assert.Equal("45216011-501e-2f32-4915-1faa1d000000", body.RequestId);
                        Assert.Equal("f15c08e0-b6a9-11e8-b16a-1d5a6655a317", body.ClientRequestId);
                        Assert.Equal("000000000000000000000000000000BF000000000042e65c", body.Sequencer);
                    }
        }
        public void Should_copy_over_EventGrid_metadata()
        {
            var message             = new CloudQueueMessage(@event);
            var transportExtensions = new TransportExtensions <AzureStorageQueueTransport>(new SettingsHolder());

            AzureStorageQueuesTransportExtensions.EnableSupportForEventGridEvents(transportExtensions);
            var wrapper = AzureStorageQueuesTransportExtensions.unwrapper(message);

            Assert.Equal("/subscriptions/<guid>/resourceGroups/<rg>/providers/Microsoft.Storage/storageAccounts/<storage-account>", wrapper.Headers["EventGrid.topic"]);
            Assert.Equal("/blobServices/default/containers/uploads/blobs/file.json", wrapper.Headers["EventGrid.subject"]);
            Assert.Equal("2018-07-19 04:05:16:366626 Z", wrapper.Headers["EventGrid.eventTime"]);
            Assert.Equal("", wrapper.Headers["EventGrid.dataVersion"]);
            Assert.Equal("1", wrapper.Headers["EventGrid.metadataVersion"]);
            Assert.Equal("Microsoft.Storage.BlobCreated", wrapper.Headers[Headers.EnclosedMessageTypes]);
            Assert.Equal("65216123-501e-002f-0517-1abc1d06b007", wrapper.Id);
        }
Ejemplo n.º 3
0
        public void Should_not_fail()
        {
            var @event = new MessageWrapper
            {
                MessageIntent = MessageIntentEnum.Publish,
                Headers       = new Dictionary <string, string>(),
                Id            = "12345",
                Body          = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new SomeEvent {
                    Data = "event"
                }))
            };
            var message = new CloudQueueMessage(JsonConvert.SerializeObject(@event));

            var transportExtensions = new TransportExtensions <AzureStorageQueueTransport>(new SettingsHolder());

            AzureStorageQueuesTransportExtensions.EnableSupportForEventGridEvents(transportExtensions);
            var wrapper = AzureStorageQueuesTransportExtensions.unwrapper(message);

            Assert.Equal(@event.Id, wrapper.Id);
            Assert.Equal(MessageIntentEnum.Publish, @event.MessageIntent);
            Assert.Empty(@event.Headers);
        }