Ejemplo n.º 1
0
        public void QueueTrigger_IfBoundToPocoAndMessageIsIncompatibleJson_DoesNotBind()
        {
            // Arrange
            const string         content = "123"; // A JSON int rather than a JSON object.
            IStorageAccount      account = CreateFakeStorageAccount();
            IStorageQueue        queue   = CreateQueue(account, QueueName);
            IStorageQueueMessage message = queue.CreateMessage(content);

            queue.AddMessage(message);

            // Act
            Exception exception = RunTriggerFailure <Poco>(account, typeof(BindToPocoProgram),
                                                           (s) => BindToPocoProgram.TaskSource = s);

            // Assert
            Assert.IsType <InvalidOperationException>(exception);
            Assert.Equal("Exception binding parameter 'message'", exception.Message);
            Exception innerException = exception.InnerException;

            Assert.IsType <InvalidOperationException>(innerException);
            string expectedInnerMessage = "Binding parameters to complex objects (such as 'Poco') uses Json.NET " +
                                          "serialization. \r\n1. Bind the parameter type as 'string' instead of 'Poco' to get the raw values " +
                                          "and avoid JSON deserialization, or\r\n2. Change the queue payload to be valid json. The JSON parser " +
                                          "failed: Error converting value 123 to type '" + typeof(Poco).FullName + "'. Path '', line 1, " +
                                          "position 3.\r\n";

            Assert.Equal(expectedInnerMessage, innerException.Message);
        }
Ejemplo n.º 2
0
        public void QueueTrigger_IfDequeueCountReachesMaxDequeueCount_MovesToPoisonQueue()
        {
            try
            {
                // Arrange
                const string    expectedContents = "abc";
                IStorageAccount account          = CreateFakeStorageAccount();
                IStorageQueue   queue            = CreateQueue(account, QueueName);
                queue.AddMessage(queue.CreateMessage(expectedContents));

                // Act
                RunTrigger <object>(account, typeof(MaxDequeueCountProgram),
                                    (s) => MaxDequeueCountProgram.TaskSource = s,
                                    new string[] { typeof(MaxDequeueCountProgram).FullName + ".PutInPoisonQueue" });

                // Assert
                IStorageAccountProvider storageAccountProvider = new FakeStorageAccountProvider()
                {
                    StorageAccount = new FakeStorageAccount()
                };
                Assert.Equal(new FakeQueueConfiguration(storageAccountProvider).MaxDequeueCount, MaxDequeueCountProgram.DequeueCount);
            }
            finally
            {
                MaxDequeueCountProgram.DequeueCount = 0;
            }
        }
Ejemplo n.º 3
0
        public void QueueTrigger_ProvidesPocoComplexPropertyBindingData()
        {
            // Arrange
            Poco expectedChild = new Poco
            {
                Value      = "abc",
                Int32Value = 123
            };
            IStorageAccount account = CreateFakeStorageAccount();
            IStorageQueue   queue   = CreateQueue(account, QueueName);
            Poco            value   = new Poco {
                Child = expectedChild
            };
            string content = JsonConvert.SerializeObject(value, typeof(Poco), settings: null);
            IStorageQueueMessage message = queue.CreateMessage(content);

            queue.AddMessage(message);

            // Act
            Poco result = RunTrigger <Poco>(account, typeof(BindToPocoComplexPropertyBindingDataProgram),
                                            (s) => BindToPocoComplexPropertyBindingDataProgram.TaskSource = s);

            // Assert
            AssertEqual(expectedChild, result);
        }
Ejemplo n.º 4
0
        public void TableEntity_IfUpdatesPoco_Persists()
        {
            // Arrange
            const string    originalValue = "abc";
            const string    expectedValue = "def";
            IStorageAccount account       = CreateFakeStorageAccount();
            IStorageQueue   triggerQueue  = CreateQueue(account, TriggerQueueName);

            triggerQueue.AddMessage(triggerQueue.CreateMessage(expectedValue));

            IStorageTable table = CreateTable(account, TableName);
            Dictionary <string, EntityProperty> originalProperties = new Dictionary <string, EntityProperty>
            {
                { "Value", new EntityProperty(originalValue) }
            };

            table.Insert(new DynamicTableEntity(PartitionKey, RowKey, etag: null, properties: originalProperties));

            // Act
            RunTrigger(account, typeof(UpdatePocoProgram));

            // Assert
            DynamicTableEntity entity = table.Retrieve <DynamicTableEntity>(PartitionKey, RowKey);

            Assert.NotNull(entity);
            IDictionary <string, EntityProperty> properties = entity.Properties;

            Assert.NotNull(properties);
            Assert.True(properties.ContainsKey("Value"));
            EntityProperty property = properties["Value"];

            Assert.NotNull(property);
            Assert.Equal(EdmType.String, property.PropertyType);
            Assert.Equal(expectedValue, property.StringValue);
        }
Ejemplo n.º 5
0
        public void Table_IfBoundToICollectorJObject_AddInsertsEntity()
        {
            // Arrange
            const string    expectedValue = "abc";
            IStorageAccount account       = CreateFakeStorageAccount();
            IStorageQueue   triggerQueue  = CreateQueue(account, TriggerQueueName);

            triggerQueue.AddMessage(triggerQueue.CreateMessage(expectedValue));

            // Act
            RunTrigger(account, typeof(BindToICollectorJObjectProgram));

            // Assert
            IStorageTableClient client = account.CreateTableClient();
            IStorageTable       table  = client.GetTableReference(TableName);

            Assert.True(table.Exists());
            DynamicTableEntity entity = table.Retrieve <DynamicTableEntity>(PartitionKey, RowKey);

            Assert.NotNull(entity);
            Assert.NotNull(entity.Properties);

            AssertPropertyValue(entity, "ValueStr", "abcdef");
            AssertPropertyValue(entity, "ValueNum", 123);
        }
Ejemplo n.º 6
0
        public void TableEntity_IfBoundToExistingDynamicTableEntity_Binds()
        {
            // Arrange
            const string    expectedKey   = "abc";
            const int       expectedValue = 123;
            IStorageAccount account       = CreateFakeStorageAccount();
            IStorageQueue   triggerQueue  = CreateQueue(account, TriggerQueueName);

            triggerQueue.AddMessage(triggerQueue.CreateMessage("ignore"));

            IStorageTable table = CreateTable(account, TableName);
            Dictionary <string, EntityProperty> properties = new Dictionary <string, EntityProperty>
            {
                { expectedKey, new EntityProperty(expectedValue) }
            };

            table.Insert(new DynamicTableEntity(PartitionKey, RowKey, etag: null, properties: properties));

            // Act
            DynamicTableEntity result = RunTrigger <DynamicTableEntity>(account, typeof(BindToDynamicTableEntityProgram),
                                                                        (s) => BindToDynamicTableEntityProgram.TaskSource = s);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(PartitionKey, result.PartitionKey);
            Assert.Equal(RowKey, result.RowKey);
            Assert.NotNull(result.Properties);
            Assert.True(result.Properties.ContainsKey(expectedKey));
            EntityProperty property = result.Properties[expectedKey];

            Assert.NotNull(property);
            Assert.Equal(EdmType.Int32, property.PropertyType);
            Assert.Equal(expectedValue, property.Int32Value);
        }
Ejemplo n.º 7
0
        public void TableEntity_IfBoundToExistingPoco_Binds()
        {
            // Arrange
            const string    expectedValue = "abc";
            IStorageAccount account       = CreateFakeStorageAccount();
            IStorageQueue   triggerQueue  = CreateQueue(account, TriggerQueueName);

            triggerQueue.AddMessage(triggerQueue.CreateMessage("ignore"));

            IStorageTable table = CreateTable(account, TableName);
            Dictionary <string, EntityProperty> properties = new Dictionary <string, EntityProperty>
            {
                { "Value", new EntityProperty(expectedValue) }
            };

            table.Insert(new DynamicTableEntity(PartitionKey, RowKey, etag: null, properties: properties));

            // Act
            Poco result = RunTrigger <Poco>(account, typeof(BindToPocoProgram),
                                            (s) => BindToPocoProgram.TaskSource = s);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(expectedValue, result.Value);
        }
Ejemplo n.º 8
0
        public void TableEntity_IfUpdatesRowKey_Throws()
        {
            // Arrange
            IStorageAccount account      = CreateFakeStorageAccount();
            IStorageQueue   triggerQueue = CreateQueue(account, TriggerQueueName);

            triggerQueue.AddMessage(triggerQueue.CreateMessage("ignore"));

            IStorageTable table = CreateTable(account, TableName);

            table.Insert(new DynamicTableEntity(PartitionKey, RowKey));

            // Act
            Exception exception = RunTriggerFailure(account, typeof(UpdatePocoRowKeyProgram));

            // Assert
            Assert.NotNull(exception);
            Assert.IsType <InvalidOperationException>(exception);
            Assert.Equal("Error while handling parameter entity after function returned:", exception.Message);
            Exception innerException = exception.InnerException;

            Assert.NotNull(innerException);
            Assert.IsType <InvalidOperationException>(innerException);
            Assert.Equal("When binding to a table entity, the row key must not be changed.", innerException.Message);
        }
Ejemplo n.º 9
0
        public void TableEntity_IfUpdatesPoco_PersistsUsingNativeTableTypes()
        {
            // Arrange
            byte[]          originalValue = new byte[] { 0x12, 0x34 };
            byte[]          expectedValue = new byte[] { 0x56, 0x78 };
            IStorageAccount account       = CreateFakeStorageAccount();
            IStorageQueue   triggerQueue  = CreateQueue(account, TriggerQueueName);

            triggerQueue.AddMessage(triggerQueue.CreateMessage(expectedValue));

            IStorageTable table = CreateTable(account, TableName);
            Dictionary <string, EntityProperty> originalProperties = new Dictionary <string, EntityProperty>
            {
                { "Value", new EntityProperty(originalValue) }
            };

            table.Insert(new DynamicTableEntity(PartitionKey, RowKey, etag: null, properties: originalProperties));

            // Act
            RunTrigger(account, typeof(UpdatePocoWithByteArrayValueProgram));

            // Assert
            DynamicTableEntity entity = table.Retrieve <DynamicTableEntity>(PartitionKey, RowKey);

            Assert.NotNull(entity);
            IDictionary <string, EntityProperty> properties = entity.Properties;

            Assert.NotNull(properties);
            Assert.True(properties.ContainsKey("Value"));
            EntityProperty property = properties["Value"];

            Assert.NotNull(property);
            Assert.Equal(EdmType.Binary, property.PropertyType);
            Assert.Equal(expectedValue, property.BinaryValue);
        }
        public void Trigger_IfClassConstructorHasDependencies_CanUseCustomJobActivator()
        {
            // Arrange
            const string expectedResult = "abc";

            Mock <IFactory <string> > resultFactoryMock = new Mock <IFactory <string> >(MockBehavior.Strict);

            resultFactoryMock.Setup(f => f.Create()).Returns(expectedResult);
            IFactory <string> resultFactory = resultFactoryMock.Object;

            Mock <IJobActivator> activatorMock = new Mock <IJobActivator>(MockBehavior.Strict);

            activatorMock.Setup(a => a.CreateInstance <InstanceCustomActivatorProgram>())
            .Returns(() => new InstanceCustomActivatorProgram(resultFactory));
            IJobActivator activator = activatorMock.Object;

            CloudQueueMessage message = new CloudQueueMessage("ignore");
            IStorageAccount   account = CreateFakeStorageAccount();
            IStorageQueue     queue   = CreateQueue(account, QueueName);

            queue.AddMessage(new FakeStorageQueueMessage(message));

            // Act
            string result = RunTrigger <string>(account, typeof(InstanceCustomActivatorProgram),
                                                (s) => InstanceCustomActivatorProgram.TaskSource = s, activator);

            // Assert
            Assert.Same(expectedResult, result);
        }
Ejemplo n.º 11
0
        public void QueueTrigger_IfBoundToPocoAndMessageIsNotJson_DoesNotBind()
        {
            // Arrange
            const string         content = "not json"; // Not a valid JSON byte sequence.
            IStorageAccount      account = CreateFakeStorageAccount();
            IStorageQueue        queue   = CreateQueue(account, QueueName);
            IStorageQueueMessage message = queue.CreateMessage(content);

            queue.AddMessage(message);

            // Act
            Exception exception = RunTriggerFailure <Poco>(account, typeof(BindToPocoProgram),
                                                           (s) => BindToPocoProgram.TaskSource = s);

            // Assert
            Assert.IsType <InvalidOperationException>(exception);
            Assert.Equal("Exception binding parameter 'message'", exception.Message);
            Exception innerException = exception.InnerException;

            Assert.IsType <InvalidOperationException>(innerException);
            const string expectedInnerMessage = "Binding parameters to complex objects (such as 'Poco') uses " +
                                                "Json.NET serialization. \r\n1. Bind the parameter type as 'string' instead of 'Poco' to get the raw " +
                                                "values and avoid JSON deserialization, or\r\n2. Change the queue payload to be valid json. The JSON " +
                                                "parser failed: Unexpected character encountered while parsing value: n. Path '', line 0, position " +
                                                "0.\r\n";

            Assert.Equal(expectedInnerMessage, innerException.Message);
        }
Ejemplo n.º 12
0
        public void Table_IfBoundToICollectorPoco_AddInsertsEntity()
        {
            // Arrange
            const string    expectedValue = "abc";
            IStorageAccount account       = CreateFakeStorageAccount();
            IStorageQueue   triggerQueue  = CreateQueue(account, TriggerQueueName);

            triggerQueue.AddMessage(triggerQueue.CreateMessage(expectedValue));

            // Act
            RunTrigger(account, typeof(BindToICollectorPocoProgram));

            // Assert
            IStorageTableClient client = account.CreateTableClient();
            IStorageTable       table  = client.GetTableReference(TableName);

            Assert.True(table.Exists());
            DynamicTableEntity entity = table.Retrieve <DynamicTableEntity>(PartitionKey, RowKey);

            Assert.NotNull(entity);
            Assert.NotNull(entity.Properties);
            Assert.True(entity.Properties.ContainsKey(PropertyName));
            EntityProperty property = entity.Properties[PropertyName];

            Assert.NotNull(property);
            Assert.Equal(EdmType.String, property.PropertyType);
            Assert.Equal(expectedValue, property.StringValue);
        }
        public void Trigger_IfClassIsDisposable_Disposes()
        {
            // Arrange
            CloudQueueMessage expectedMessage = new CloudQueueMessage("ignore");
            IStorageAccount   account         = CreateFakeStorageAccount();
            IStorageQueue     queue           = CreateQueue(account, QueueName);

            queue.AddMessage(new FakeStorageQueueMessage(expectedMessage));

            // Act & Assert
            RunTrigger <object>(account, typeof(DisposeInstanceProgram),
                                (s) => DisposeInstanceProgram.TaskSource = s);
        }
Ejemplo n.º 14
0
        public void Table_IfBoundToICollectorPoco_AddInsertsEntity()
        {
            // Arrange
            const string    expectedValue = "abc";
            IStorageAccount account       = CreateFakeStorageAccount();
            IStorageQueue   triggerQueue  = CreateQueue(account, TriggerQueueName);

            triggerQueue.AddMessage(triggerQueue.CreateMessage(expectedValue));

            // Act
            RunTrigger(account, typeof(BindToICollectorPocoProgram));

            // Assert
            AssertStringProperty(account, PropertyName, expectedValue);
        }
Ejemplo n.º 15
0
        private static void TestBindToByteArray(byte[] expectedContent)
        {
            // Arrange
            IStorageAccount      account = CreateFakeStorageAccount();
            IStorageQueue        queue   = CreateQueue(account, QueueName);
            IStorageQueueMessage message = queue.CreateMessage(expectedContent);

            queue.AddMessage(message);

            // Act
            byte[] result = RunTrigger <byte[]>(account, typeof(BindToByteArrayProgram),
                                                (s) => BindToByteArrayProgram.TaskSource = s);

            // Assert
            Assert.Equal(expectedContent, result);
        }
Ejemplo n.º 16
0
        private static void TestBindToPoco(Poco expectedContent)
        {
            // Arrange
            IStorageAccount      account = CreateFakeStorageAccount();
            IStorageQueue        queue   = CreateQueue(account, QueueName);
            string               content = JsonConvert.SerializeObject(expectedContent, typeof(Poco), settings: null);
            IStorageQueueMessage message = queue.CreateMessage(content);

            queue.AddMessage(message);

            // Act
            Poco result = RunTrigger <Poco>(account, typeof(BindToPocoProgram), (s) => BindToPocoProgram.TaskSource = s);

            // Assert
            AssertEqual(expectedContent, result);
        }
Ejemplo n.º 17
0
        private static void TestBindToString(string expectedContent)
        {
            // Arrange
            IStorageAccount      account = CreateFakeStorageAccount();
            IStorageQueue        queue   = CreateQueue(account, QueueName);
            IStorageQueueMessage message = queue.CreateMessage(expectedContent);

            queue.AddMessage(message);

            // Act
            string result = RunTrigger <string>(account, typeof(BindToStringProgram),
                                                (s) => BindToStringProgram.TaskSource = s);

            // Assert
            Assert.Same(expectedContent, result);
        }
        public void Trigger_CanBeAsyncInstanceMethod()
        {
            // Arrange
            CloudQueueMessage expectedMessage = new CloudQueueMessage("ignore");
            IStorageAccount   account         = CreateFakeStorageAccount();
            IStorageQueue     queue           = CreateQueue(account, QueueName);

            queue.AddMessage(new FakeStorageQueueMessage(expectedMessage));

            // Act
            CloudQueueMessage result = RunTrigger <CloudQueueMessage>(account, typeof(InstanceAsyncProgram),
                                                                      (s) => InstanceAsyncProgram.TaskSource = s);

            // Assert
            Assert.Same(expectedMessage, result);
        }
Ejemplo n.º 19
0
        public void QueueTrigger_IfBoundToCloudQueueMessage_Binds()
        {
            // Arrange
            CloudQueueMessage expectedMessage = new CloudQueueMessage("ignore");
            IStorageAccount   account         = CreateFakeStorageAccount();
            IStorageQueue     queue           = CreateQueue(account, QueueName);

            queue.AddMessage(new FakeStorageQueueMessage(expectedMessage));

            // Act
            CloudQueueMessage result = RunTrigger <CloudQueueMessage>(account, typeof(BindToCloudQueueMessageProgram),
                                                                      (s) => BindToCloudQueueMessageProgram.TaskSource = s);

            // Assert
            Assert.Same(expectedMessage, result);
        }
Ejemplo n.º 20
0
        public void Trigger_CanBeAsyncInstanceMethod()
        {
            // Arrange
            string            expectedGuid    = Guid.NewGuid().ToString();
            CloudQueueMessage expectedMessage = new CloudQueueMessage(expectedGuid);
            IStorageAccount   account         = CreateFakeStorageAccount();
            IStorageQueue     queue           = CreateQueue(account, QueueName);

            queue.AddMessage(new FakeStorageQueueMessage(expectedMessage));

            // Act
            CloudQueueMessage result = RunTrigger <CloudQueueMessage>(account, typeof(InstanceAsyncProgram),
                                                                      (s) => InstanceAsyncProgram.TaskSource = s);

            // Assert
            Assert.Equal(expectedGuid, result.AsString);
        }
Ejemplo n.º 21
0
        public void QueueTrigger_IfBoundToCloudQueueMessage_Binds()
        {
            // Arrange
            string            expectedGuid    = Guid.NewGuid().ToString();
            CloudQueueMessage expectedMessage = new CloudQueueMessage(expectedGuid);
            IStorageAccount   account         = CreateFakeStorageAccount();
            IStorageQueue     queue           = CreateQueue(account, QueueName);

            queue.AddMessage(new FakeStorageQueueMessage(expectedMessage));

            // Act
            CloudQueueMessage result = RunTrigger <CloudQueueMessage>(account, typeof(BindToCloudQueueMessageProgram),
                                                                      (s) => BindToCloudQueueMessageProgram.TaskSource = s);

            // Assert
            Assert.Equal(expectedMessage.AsString, result.AsString);
        }
Ejemplo n.º 22
0
        public void Trigger_ViaIBinder_CannotBind()
        {
            // Arrange
            const string            expectedContents = "abc";
            IStorageAccount         account          = CreateFakeStorageAccount();
            IStorageQueue           queue            = CreateQueue(account, QueueName);
            FakeStorageQueueMessage message          = (FakeStorageQueueMessage)queue.CreateMessage(expectedContents);

            queue.AddMessage(message);

            // Act
            Exception exception = RunTriggerFailure <string>(account, typeof(BindToQueueTriggerViaIBinderProgram),
                                                             (s) => BindToQueueTriggerViaIBinderProgram.TaskSource = s);

            // Assert
            Assert.Equal("No binding found for attribute 'Microsoft.Azure.WebJobs.QueueTriggerAttribute'.", exception.Message);
        }
Ejemplo n.º 23
0
        public void QueueTrigger_IfBindingAlwaysFails_MovesToPoisonQueue()
        {
            // Arrange
            const string    expectedContents = "abc";
            IStorageAccount account          = CreateFakeStorageAccount();
            IStorageQueue   queue            = CreateQueue(account, QueueName);

            queue.AddMessage(queue.CreateMessage(expectedContents));

            // Act
            string result = RunTrigger <string>(account, typeof(PoisonQueueProgram),
                                                (s) => PoisonQueueProgram.TaskSource = s,
                                                new string[] { typeof(PoisonQueueProgram).FullName + ".PutInPoisonQueue" });

            // Assert
            Assert.Equal(expectedContents, result);
        }
Ejemplo n.º 24
0
        public void QueueTrigger_ProvidesNextVisibleTimeBindingData()
        {
            // Arrange
            IStorageAccount      account = CreateFakeStorageAccount();
            IStorageQueue        queue   = CreateQueue(account, QueueName);
            IStorageQueueMessage message = queue.CreateMessage("ignore");

            // message.NextVisibleTime is provided by FakeStorageAccount when the message is retrieved.
            queue.AddMessage(message);

            // Act
            DateTimeOffset result = RunTrigger <DateTimeOffset>(account, typeof(BindToNextVisibleTimeBindingDataProgram),
                                                                (s) => BindToNextVisibleTimeBindingDataProgram.TaskSource = s);

            // Assert
            Assert.Equal(0, (int)DateTimeOffset.Now.Subtract(result).TotalHours);
        }
Ejemplo n.º 25
0
        public void QueueTrigger_ProvidesDequeueCountBindingData()
        {
            // Arrange
            IStorageAccount      account = CreateFakeStorageAccount();
            IStorageQueue        queue   = CreateQueue(account, QueueName);
            IStorageQueueMessage message = queue.CreateMessage("ignore");

            // message.DequeueCount is provided by FakeStorageAccount when the message is retrieved.
            queue.AddMessage(message);

            // Act
            int result = RunTrigger <int>(account, typeof(BindToDequeueCountBindingDataProgram),
                                          (s) => BindToDequeueCountBindingDataProgram.TaskSource = s);

            // Assert
            Assert.Equal(1, result);
        }
Ejemplo n.º 26
0
        public void QueueTrigger_IfMessageIsString_ProvidesQueueTriggerBindingData()
        {
            // Arrange
            const string         expectedQueueTrigger = "abc";
            IStorageAccount      account = CreateFakeStorageAccount();
            IStorageQueue        queue   = CreateQueue(account, QueueName);
            IStorageQueueMessage message = queue.CreateMessage(expectedQueueTrigger);

            queue.AddMessage(message);

            // Act
            string result = RunTrigger <string>(account, typeof(BindToQueueTriggerBindingDataProgram),
                                                (s) => BindToQueueTriggerBindingDataProgram.TaskSource = s);

            // Assert
            Assert.Same(expectedQueueTrigger, result);
        }
Ejemplo n.º 27
0
        public void QueueTrigger_IfBoundToPocoStruct_Binds()
        {
            // Arrange
            const int            expectedContent = 123;
            IStorageAccount      account         = CreateFakeStorageAccount();
            IStorageQueue        queue           = CreateQueue(account, QueueName);
            string               content         = JsonConvert.SerializeObject(expectedContent, typeof(int), settings: null);
            IStorageQueueMessage message         = queue.CreateMessage(content);

            queue.AddMessage(message);

            // Act
            int result = RunTrigger <int>(account, typeof(BindToPocoStructProgram),
                                          (s) => BindToPocoStructProgram.TaskSource = s);

            // Assert
            Assert.Equal(expectedContent, result);
        }
Ejemplo n.º 28
0
        public void Table_IfBoundToCloudTable_BindsAndCreatesTable()
        {
            // Arrange
            IStorageAccount account = CreateFakeStorageAccount();
            IStorageQueue triggerQueue = CreateQueue(account, TriggerQueueName);
            triggerQueue.AddMessage(triggerQueue.CreateMessage("ignore"));

            // Act
            CloudTable result = RunTrigger<CloudTable>(account, typeof(BindToCloudTableProgram),
                (s) => BindToCloudTableProgram.TaskSource = s);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(TableName, result.Name);
            IStorageTableClient client = account.CreateTableClient();
            IStorageTable table = client.GetTableReference(TableName);
            Assert.True(table.Exists());
        }
Ejemplo n.º 29
0
        public void QueueTrigger_ProvidesPopReceiptBindingData()
        {
            // Arrange
            IStorageAccount      account = CreateFakeStorageAccount();
            IStorageQueue        queue   = CreateQueue(account, QueueName);
            IStorageQueueMessage message = queue.CreateMessage("ignore");

            // message.PopReceipt is provided by FakeStorageAccount when the message is retrieved.
            queue.AddMessage(message);

            // Act
            string result = RunTrigger <string>(account, typeof(BindToPopReceiptBindingDataProgram),
                                                (s) => BindToPopReceiptBindingDataProgram.TaskSource = s);

            // Assert
            Assert.NotNull(result);
            Assert.NotEmpty(result);
        }
Ejemplo n.º 30
0
        public void QueueTrigger_IfMessageIsUtf8ByteArray_ProvidesQueueTriggerBindingData()
        {
            // Arrange
            const string expectedQueueTrigger = "abc";

            byte[]               content = StrictEncodings.Utf8.GetBytes(expectedQueueTrigger);
            IStorageAccount      account = CreateFakeStorageAccount();
            IStorageQueue        queue   = CreateQueue(account, QueueName);
            IStorageQueueMessage message = queue.CreateMessage(content);

            queue.AddMessage(message);

            // Act
            string result = RunTrigger <string>(account, typeof(BindToQueueTriggerBindingDataProgram),
                                                (s) => BindToQueueTriggerBindingDataProgram.TaskSource = s);

            // Assert
            Assert.Equal(expectedQueueTrigger, result);
        }