Example #1
0
        public void DeclaredMembersVerifier_should_verify_open_generic_methods_to_be_closed_with_any_types()
        {
            var genericMethod = typeof(TestKnownStaticType).GetMethod(nameof(TestKnownStaticType.GetTypeNameOf));
            var allowedExpr1  = Expression.Call(GetMethodInfo(() => TestKnownStaticType.GetTypeNameOf <string>()));
            var allowedExpr2  = Expression.Call(GetMethodInfo(() => TestKnownStaticType.GetTypeNameOf <int>()));
            var verify        = Create(CreateDeclaredMembersVerifier(genericMethod));

            var verified1 = verify(allowedExpr1);
            var verified2 = verify(allowedExpr2);

            AssertVerified(verified1);
            AssertVerified(verified2);
        }
Example #2
0
        public void DeclaredMembersVerifier_should_verify_closed_generic_methods()
        {
            var allowedMethod    = GetMethodInfo(() => TestKnownStaticType.GetTypeNameOf <string>());
            var disallowedMethod = GetMethodInfo(() => TestKnownStaticType.GetTypeNameOf <int>());
            var allowedExpr      = Expression.Call(allowedMethod);
            var disallowedExpr   = Expression.Call(disallowedMethod);
            var verify           = Create(CreateDeclaredMembersVerifier(allowedMethod));

            var verified = verify(allowedExpr);
            var refuted  = verify(disallowedExpr);

            AssertVerified(verified);
            AssertRefuted(refuted);
        }