Пример #1
0
        public async Task InvokeStringBlobAttribute()
        {
            foreach (var attr in new BlobAttribute[] {
                new BlobAttribute("container/{name}"),
                new BlobAttribute("container/constant", FileAccess.ReadWrite),
                new BlobAttribute("container/{name}", FileAccess.Write)
            })
            {
                var           cloner = new AttributeCloner <BlobAttribute>(attr, GetBindingContract("name"));
                BlobAttribute attr2  = await cloner.ResolveFromInvokeStringAsync("c/n");

                Assert.Equal("c/n", attr2.BlobPath);
                Assert.Equal(attr.Access, attr2.Access);
            }
        }
Пример #2
0
        public async Task InvokeString()
        {
            Attr1 a1 = new Attr1 {
                Path = "%test%"
            };

            Assert.Null(a1 as IAttributeInvokeDescriptor <Attr1>); // Does not implement the interface

            var nameResolver = new FakeNameResolver();

            nameResolver._dict["test"] = "ABC";

            var   cloner = new AttributeCloner <Attr1>(a1, EmptyContract, nameResolver);
            Attr1 attr2  = await cloner.ResolveFromInvokeStringAsync("xy");

            Assert.Equal("xy", attr2.Path);
        }
Пример #3
0
        public async Task InvokeStringMultipleResolvedProperties()
        {
            Attr2 attr = new Attr2("{p2}", "constant")
            {
                ResolvedProp1 = "{p1}"
            };

            var cloner = new AttributeCloner <Attr2>(attr, GetBindingContract("p1", "p2"));

            Attr2 attrResolved = cloner.ResolveFromBindings(new Dictionary <string, object> {
                { "p1", "v1" }, { "p2", "v2" }
            });

            Assert.Equal("v1", attrResolved.ResolvedProp1);
            Assert.Equal("v2", attrResolved.ResolvedProp2);
            Assert.Equal(attr.ConstantProp, attrResolved.ConstantProp);

            var invokeString = cloner.GetInvokeString(attrResolved);
            var attr2        = await cloner.ResolveFromInvokeStringAsync(invokeString);

            Assert.Equal(attrResolved.ResolvedProp1, attr2.ResolvedProp1);
            Assert.Equal(attrResolved.ResolvedProp2, attr2.ResolvedProp2);
            Assert.Equal(attrResolved.ConstantProp, attr2.ConstantProp);
        }
        public async Task InvokeStringBlobAttribute()
        {
            foreach (var attr in new BlobAttribute[] {
                new BlobAttribute("container/{name}"),
                new BlobAttribute("container/constant", FileAccess.ReadWrite),
                new BlobAttribute("container/{name}", FileAccess.Write)
            })
            {
                var cloner = new AttributeCloner<BlobAttribute>(attr, GetBindingContract("name"));
                BlobAttribute attr2 = await cloner.ResolveFromInvokeStringAsync("c/n");

                Assert.Equal("c/n", attr2.BlobPath);
                Assert.Equal(attr.Access, attr2.Access);
            }
        }
        public async Task InvokeString()
        {
            Attr1 a1 = new Attr1 { Path = "%test%" };

            Assert.Null(a1 as IAttributeInvokeDescriptor<Attr1>); // Does not implement the interface

            var nameResolver = new FakeNameResolver();
            nameResolver._dict["test"] = "ABC";

            var cloner = new AttributeCloner<Attr1>(a1, EmptyContract, nameResolver);
            Attr1 attr2 = await cloner.ResolveFromInvokeStringAsync("xy");

            Assert.Equal("xy", attr2.Path);
        }
        public async Task InvokeStringMultipleResolvedProperties()
        {
            Attr2 attr = new Attr2("{p2}", "constant") { ResolvedProp1 = "{p1}" };

            var cloner = new AttributeCloner<Attr2>(attr, GetBindingContract("p1", "p2"));

            Attr2 attrResolved = cloner.ResolveFromBindings(new Dictionary<string, object> {
                { "p1", "v1" }, { "p2", "v2" }});

            Assert.Equal("v1", attrResolved.ResolvedProp1);
            Assert.Equal("v2", attrResolved.ResolvedProp2);
            Assert.Equal(attr.ConstantProp, attrResolved.ConstantProp);

            var invokeString = cloner.GetInvokeString(attrResolved);
            var attr2 = await cloner.ResolveFromInvokeStringAsync(invokeString);

            Assert.Equal(attrResolved.ResolvedProp1, attr2.ResolvedProp1);
            Assert.Equal(attrResolved.ResolvedProp2, attr2.ResolvedProp2);
            Assert.Equal(attrResolved.ConstantProp, attr2.ConstantProp);
        }