コード例 #1
0
        public void TryAutoResolveValue_UnresolvedValue_ThrowsExpectedException()
        {
            var resolver  = new FakeNameResolver();
            var attribute = new Attr2(string.Empty, string.Empty)
            {
                ResolvedSetting = "MySetting"
            };
            var    prop          = attribute.GetType().GetProperty("ResolvedSetting");
            string resolvedValue = null;

            var ex = Assert.Throws <InvalidOperationException>(() => AttributeCloner <Attr2> .TryAutoResolveValue(attribute, prop, resolver, out resolvedValue));

            Assert.Equal("Unable to resolve value for property 'Attr2.ResolvedSetting'.", ex.Message);
        }
コード例 #2
0
        public void TryAutoResolveValue_UnresolvedValue_ThrowsExpectedException()
        {
            var resolver  = new FakeNameResolver();
            var attribute = new Attr2(string.Empty, string.Empty)
            {
                ResolvedSetting = "MySetting"
            };
            var    prop          = attribute.GetType().GetProperty("ResolvedSetting");
            var    attr          = prop.GetCustomAttribute <AppSettingAttribute>();
            string resolvedValue = "MySetting";

            var ex = Assert.Throws <InvalidOperationException>(() => AttributeCloner <Attr2> .GetAppSettingResolver(resolvedValue, attr, resolver, prop, skipValidation));

            Assert.Contains("Unable to resolve app setting for property 'Attr2.ResolvedSetting'.", ex.Message);
        }