Example #1
0
        public void Inherited()
        {
            const string name      = nameof(IDictionary <object, object> .Keys);
            var          ignore    = typeof(IDictionary <,>).GetRuntimeProperty(name);
            var          sut       = new BlacklistMemberPolicy(ignore);
            var          instance  = new Dictionary();
            var          type      = instance.GetType();
            var          candidate = type.GetRuntimeProperty(name);
            var          allowed   = sut.IsSatisfiedBy(candidate);

            Assert.False(allowed);
        }
        public void Blacklist()
        {
            const string name      = nameof(IDictionary <object, object> .Keys);
            var          ignore    = typeof(IDictionary <,>).GetRuntimeProperty(name);
            var          sut       = new BlacklistMemberPolicy(ignore);
            var          instance  = new Dictionary <string, int>();
            var          type      = instance.GetType();
            var          candidate = type.GetRuntimeProperty(name);
            var          allowed   = sut.IsSatisfiedBy(candidate);

            Assert.False(allowed);

            foreach (var property in type.GetRuntimeProperties().Except(candidate.Yield()))
            {
                Assert.True(sut.IsSatisfiedBy(property));
            }
        }