Beispiel #1
0
        public void GetMetadataForMixinType_Wrappers()
        {
            var importerMock       = new MockRepository().PartialMock <AttributeBasedMetadataImporter> ();
            var expectedIdentifier = new ConcreteMixinTypeIdentifier(typeof(object), new HashSet <MethodInfo> (), new HashSet <MethodInfo> ());

            var method1  = ReflectionObjectMother.GetSomeNonPublicMethod();
            var method2  = typeof(DateTime).GetMethod("get_InternalTicks", BindingFlags.NonPublic | BindingFlags.Instance);
            var wrapper1 = typeof(DateTime).GetMethod("get_Month");
            var wrapper2 = typeof(DateTime).GetMethod("get_Year");

            SetupImporterMock(
                importerMock,
                expectedIdentifier,
                new Dictionary <MethodInfo, MethodInfo> (),
                new Dictionary <MethodInfo, MethodInfo> {
                { method1, wrapper1 }, { method2, wrapper2 }
            });
            importerMock.Replay();

            var result = importerMock.GetMetadataForMixinType(typeof(LoadableConcreteMixinTypeForMixinWithAbstractMembers));

            Assert.That(result.GetPubliclyCallableMixinMethod(method1), Is.EqualTo(wrapper1));
            Assert.That(result.GetPubliclyCallableMixinMethod(method2), Is.EqualTo(wrapper2));

            importerMock.VerifyAllExpectations();
        }
Beispiel #2
0
        public void SetUp()
        {
            var identifier = new ConcreteMixinTypeIdentifier(typeof(object), new HashSet <MethodInfo> (), new HashSet <MethodInfo> ());

            _nonPublicMethod          = ReflectionObjectMother.GetSomeNonPublicMethod();
            _publicMethod             = ReflectionObjectMother.GetSomePublicMethod();
            _wrapperOrInterfaceMethod = ReflectionObjectMother.GetSomeMethod();
            _concreteMixinType        = new ConcreteMixinType(
                identifier,
                typeof(object),
                typeof(IServiceProvider),
                new Dictionary <MethodInfo, MethodInfo> {
                { _nonPublicMethod, _wrapperOrInterfaceMethod }
            },
                new Dictionary <MethodInfo, MethodInfo> {
                { _nonPublicMethod, _wrapperOrInterfaceMethod }
            });
        }