Example #1
0
        public void GetAttributeBuilderInfo_DocumentDBAttribute()
        {
            DocumentDBAttribute attribute = new DocumentDBAttribute("myDb", "myCollection")
            {
                CreateIfNotExists       = true,
                ConnectionStringSetting = "myConnection",
                PartitionKey            = "myPartition",
                Id = "myId",
                CollectionThroughput = 123
            };
            var builderInfo = ExtensionBinding.GetAttributeBuilderInfo(attribute);

            DocumentDBAttribute result = (DocumentDBAttribute)builderInfo.Constructor.Invoke(builderInfo.ConstructorArgs);

            Assert.Equal(attribute.DatabaseName, result.DatabaseName);
            Assert.Equal(attribute.CollectionName, result.CollectionName);

            Assert.Equal(5, builderInfo.Properties.Count);

            var properties = builderInfo.Properties.ToDictionary(p => p.Key.Name, p => p.Value);

            Assert.True((bool)properties["CreateIfNotExists"]);
            Assert.Equal("myConnection", (string)properties["ConnectionStringSetting"]);
            Assert.Equal("myPartition", (string)properties["PartitionKey"]);
            Assert.Equal("myId", (string)properties["Id"]);
            Assert.Equal(123, (int)properties["CollectionThroughput"]);
        }
Example #2
0
        public void GetAttributeBuilderInfo_ReturnsExpectedAttribute()
        {
            var attribute = new TestAttribute("constructorSetAttributeValue")
            {
                BoolParameter               = true,
                StringParameter             = "stringParameterValue",
                IntParameter                = 42,
                DoesNotAutoResolveParameter = "doesNotAutoResolveParameterValue"
            };
            var builderInfo = ExtensionBinding.GetAttributeBuilderInfo(attribute);

            TestAttribute result = (TestAttribute)builderInfo.Constructor.Invoke(builderInfo.ConstructorArgs);

            Assert.Equal(attribute.ConstructorSetParameter, result.ConstructorSetParameter);

            // 6 properties on the object, but AppSetting will be null, so 5 will be expected.
            Assert.Equal(5, builderInfo.Properties.Count);

            var properties = builderInfo.Properties.ToDictionary(p => p.Key.Name, p => p.Value);

            Assert.Throws(typeof(KeyNotFoundException), () => properties["AppSettingSetParameter"]);
            Assert.Equal(attribute.BoolParameter, (bool)properties["BoolParameter"]);
            Assert.Equal(attribute.ConstructorSetParameter, (string)properties["ConstructorSetParameter"]);
            Assert.Equal(attribute.DoesNotAutoResolveParameter, (string)properties["DoesNotAutoResolveParameter"]);
            Assert.Equal(attribute.IntParameter, (int)properties["IntParameter"]);
            Assert.Equal(attribute.StringParameter, (string)properties["StringParameter"]);
        }
Example #3
0
        public void GetAttributeBuilderInfo_ServiceBusTriggerAttribute_Queue()
        {
            ServiceBusTriggerAttribute attribute = new ServiceBusTriggerAttribute("myQueue", Microsoft.ServiceBus.Messaging.AccessRights.Listen);
            var builderInfo = ExtensionBinding.GetAttributeBuilderInfo(attribute);

            ServiceBusTriggerAttribute result = (ServiceBusTriggerAttribute)builderInfo.Constructor.Invoke(builderInfo.ConstructorArgs);

            Assert.Equal(attribute.QueueName, result.QueueName);
            Assert.Equal(attribute.Access, result.Access);
            Assert.Null(result.TopicName);
            Assert.Null(result.SubscriptionName);
            Assert.Equal(0, builderInfo.Properties.Count);
        }