Esempio n. 1
0
        public async Task Setting_Null()
        {
            Attr2 a2 = new Attr2(string.Empty, string.Empty);

            var cloner = new AttributeCloner <Attr2>(a2, EmptyContract, null);

            Attr2 a2Clone = await cloner.ResolveFromBindingDataAsync(GetCtx(null));

            Assert.Null(a2Clone.ResolvedSetting);
        }
Esempio n. 2
0
        public async Task CloneNoDefaultCtor()
        {
            var a1 = new BlobAttribute("container/{name}.txt", FileAccess.Write);

            Dictionary <string, object> values = new Dictionary <string, object>()
            {
                { "name", "green" },
            };
            var ctx = GetCtx(values);

            var cloner = new AttributeCloner <BlobAttribute>(a1, GetBindingContract("name"));
            var attr2  = await cloner.ResolveFromBindingDataAsync(ctx);

            Assert.Equal("container/green.txt", attr2.BlobPath);
            Assert.Equal(a1.Access, attr2.Access);
        }
Esempio n. 3
0
        public async Task Easy()
        {
            Attr1 a1 = new Attr1 {
                Path = "{key1}-{key2}"
            };

            Dictionary <string, object> values = new Dictionary <string, object>()
            {
                { "key1", "val1" },
                { "key2", "val2" }
            };
            var ctx = GetCtx(values);

            var cloner = new AttributeCloner <Attr1>(a1, GetBindingContract("key1", "key2"));
            var attr2  = await cloner.ResolveFromBindingDataAsync(ctx);

            Assert.Equal("val1-val2", attr2.Path);
        }
Esempio n. 4
0
        public async Task NameResolver()
        {
            Attr1 a1 = new Attr1 {
                Path = "x%appsetting%y-{k}"
            };

            var nameResolver = new FakeNameResolver().Add("appsetting", "ABC");
            var cloner       = new AttributeCloner <Attr1>(a1, GetBindingContract("k"), nameResolver);

            // Get the attribute with %% resolved (happens at indexing time), but not {} (not resolved until runtime)
            var attrPre = cloner.GetNameResolvedAttribute();

            Assert.Equal("xABCy-{k}", attrPre.Path);

            Dictionary <string, object> values = new Dictionary <string, object>()
            {
                { "k", "v" }
            };
            var ctx   = GetCtx(values);
            var attr2 = await cloner.ResolveFromBindingDataAsync(ctx);

            Assert.Equal("xABCy-v", attr2.Path);
        }
        public async Task CloneNoDefaultCtorShortList()
        {
            // Use shorter parameter list.
            var a1 = new BlobAttribute("container/{name}.txt");

            Dictionary<string, object> values = new Dictionary<string, object>()
            {
                { "name", "green" },
            };
            var ctx = GetCtx(values);

            var cloner = new AttributeCloner<BlobAttribute>(a1, GetBindingContract("name"));
            var attr2 = await cloner.ResolveFromBindingDataAsync(ctx);

            Assert.Equal("container/green.txt", attr2.BlobPath);
            Assert.Equal(a1.Access, attr2.Access);
        }
        public async Task Setting_Null()
        {
            Attr2 a2 = new Attr2(string.Empty, string.Empty);

            var cloner = new AttributeCloner<Attr2>(a2, EmptyContract, null);

            Attr2 a2Clone = await cloner.ResolveFromBindingDataAsync(GetCtx(null));

            Assert.Null(a2Clone.ResolvedSetting);
        }
        public async Task Easy()
        {
            Attr1 a1 = new Attr1 { Path = "{key1}-{key2}" };

            Dictionary<string, object> values = new Dictionary<string, object>()
            {
                { "key1", "val1" },
                { "key2", "val2" }
            };
            var ctx = GetCtx(values);

            var cloner = new AttributeCloner<Attr1>(a1, GetBindingContract("key1", "key2"));
            var attr2 = await cloner.ResolveFromBindingDataAsync(ctx);

            Assert.Equal("val1-val2", attr2.Path);
        }
        public async Task NameResolver()
        {
            Attr1 a1 = new Attr1 { Path = "x%appsetting%y-{k}" };

            var nameResolver = new FakeNameResolver().Add("appsetting", "ABC");
            var cloner = new AttributeCloner<Attr1>(a1, GetBindingContract("k"), nameResolver);

            // Get the attribute with %% resolved (happens at indexing time), but not {} (not resolved until runtime)
            var attrPre = cloner.GetNameResolvedAttribute();
            Assert.Equal("xABCy-{k}", attrPre.Path);

            Dictionary<string, object> values = new Dictionary<string, object>()
            {
                { "k", "v" }
            };
            var ctx = GetCtx(values);
            var attr2 = await cloner.ResolveFromBindingDataAsync(ctx);

            Assert.Equal("xABCy-v", attr2.Path);
        }