public void AppSettingAttribute_Throws_IfDefaultUnmatched()
        {
            Attr3 a3 = new Attr3()
            {
                Required = "req"
            };

            Assert.Throws <InvalidOperationException>(() => new AttributeCloner <Attr3>(a3, emptyContract));
        }
        public void AppSettingAttribute_Resolves_IfDefaultMatched()
        {
            Attr3 a3 = new Attr3()
            {
                Required = "req"
            };
            var nameResolver = new FakeNameResolver().Add("default", "defaultval").Add("req", "reqval");
            var cloner       = new AttributeCloner <Attr3>(a3, emptyContract, nameResolver);
            var cloned       = cloner.GetNameResolvedAttribute();

            Assert.Equal("reqval", cloned.Required);
            Assert.Equal("defaultval", cloned.Default);
        }
Exemple #3
0
        public void AppSettingAttribute_Resolves_IfDefaultMatched()
        {
            Attr3 a3 = new Attr3()
            {
                Required = "req"
            };
            var nameResolver = new FakeNameResolver();

            var config = TestHelpers.CreateInMemoryCollection()
                         .AddSetting("default", "defaultval")
                         .AddSetting("req", "reqval")
                         .BuildConfiguration();

            var cloner = new AttributeCloner <Attr3>(a3, emptyContract, config, nameResolver);
            var cloned = cloner.GetNameResolvedAttribute();

            Assert.Equal("reqval", cloned.Required);
            Assert.Equal("defaultval", cloned.Default);
        }