Пример #1
0
        private static IStorageTable CreateTable(IStorageAccount account, string tableName)
        {
            IStorageTableClient client = account.CreateTableClient();
            IStorageTable       table  = client.GetTableReference(tableName);

            table.CreateIfNotExists();
            return(table);
        }
Пример #2
0
        public void Table_IfBoundToIQueryableDynamicTableEntityAndExists_Binds()
        {
            // Arrange
            Guid            expectedValue = Guid.NewGuid();
            IStorageAccount account       = CreateFakeStorageAccount();
            IStorageQueue   triggerQueue  = CreateQueue(account, TriggerQueueName);

            triggerQueue.AddMessage(triggerQueue.CreateMessage("ignore"));
            IStorageTableClient client = account.CreateTableClient();
            IStorageTable       table  = client.GetTableReference(TableName);

            table.CreateIfNotExists();
            Dictionary <string, EntityProperty> properties = new Dictionary <string, EntityProperty>
            {
                { PropertyName, new EntityProperty(expectedValue) }
            };

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

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

            // Assert
            Assert.NotNull(result);
            DynamicTableEntity[] entities = result.ToArray();
            Assert.Equal(1, entities.Length);
            DynamicTableEntity entity = entities[0];

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

            Assert.NotNull(property);
            Assert.Equal(EdmType.Guid, property.PropertyType);
            Assert.Equal(expectedValue, property.GuidValue);
        }