Exemplo n.º 1
0
        public void CallMethod_Static()
        {
            // public static bool string.IsNullOrEmpty (string aString);
            var output = ReflectedObject.CallMethod(typeof(string), "IsNullOrEmpty", "notEmpty");

            Assert.That(output.To <bool>(), Is.False);
        }
Exemplo n.º 2
0
        public void CallMethod_ExistingMethod_WithReflectedObject()
        {
            var reflectedObject = new ReflectedObject("stringContent");
            var output          = reflectedObject.CallMethod("IndexOf", new ReflectedObject('t'));

            Assert.That(output.To <int>(), Is.EqualTo(1));
        }
Exemplo n.º 3
0
        public override ReflectedObject BuildConfigurationFromAssemblies(Assembly[] assemblies)
        {
            ArgumentUtility.CheckNotNull("assemblies", assemblies);

            var declarativeConfigurationBuilderType = RemotionAssembly.GetType("Remotion.Mixins.Context.DeclarativeConfigurationBuilder", true);

            return(ReflectedObject.CallMethod(declarativeConfigurationBuilderType, "BuildConfigurationFromAssemblies", new object[] { assemblies }));
        }
Exemplo n.º 4
0
        public void CallMethod_ExistingMethod_Void()
        {
            // TargetDoSomething has method: public void DoSomething()
            var reflectedObject = new ReflectedObject(new TargetDoSomething());
            var output          = reflectedObject.CallMethod("DoSomething");

            Assert.That(output, Is.Null);
        }
Exemplo n.º 5
0
        public override ReflectedObject GetTargetClassDefinition(Type targetType, ReflectedObject mixinConfiguration, ReflectedObject classContext)
        {
            ArgumentUtility.CheckNotNull("targetType", targetType);
            ArgumentUtility.CheckNotNull("mixinConfiguration", mixinConfiguration);

            var targetClassDefinitionFactoryType = RemotionAssembly.GetType("Remotion.Mixins.Definitions.TargetClassDefinitionFactory", true);

            return(ReflectedObject.CallMethod(targetClassDefinitionFactoryType, "CreateTargetClassDefinition", classContext));
        }
Exemplo n.º 6
0
        public virtual ReflectedObject GetTargetClassDefinition(Type targetType, ReflectedObject mixinConfiguration, ReflectedObject classContext)
        {
            ArgumentUtility.CheckNotNull("targetType", targetType);
            ArgumentUtility.CheckNotNull("mixinConfiguration", mixinConfiguration);

            var targetClassDefinitionUtilityType = _remotionAssembly.GetType("Remotion.Mixins.TargetClassDefinitionUtility", true);

            return(ReflectedObject.CallMethod(targetClassDefinitionUtilityType, "GetConfiguration", targetType, mixinConfiguration));
        }
Exemplo n.º 7
0
        public override void InitializeLogging()
        {
            var    type   = RemotionAssembly.GetType("Remotion.Logging.LogManager", true);
            object logger = ReflectedObject.CallMethod(type, "GetLogger", "LoggerName");

            if (logger == null)
            {
                throw new InvalidOperationException("Failed to initialize log4net.");
            }
        }
Exemplo n.º 8
0
        public void CallMethod_NonExistingMethod()
        {
            var reflectedObject = new ReflectedObject("stringContent");

            try
            {
                reflectedObject.CallMethod("nonExistingMethod");
                Assert.Fail("expected exception not thrown");
            }
            catch (MissingMethodException missingMethodException)
            {
                Assert.That(missingMethodException.Message, Is.EqualTo("Method 'nonExistingMethod' not found on type 'System.String'."));
            }
        }
Exemplo n.º 9
0
 private ReflectedObject GetMixinDefiniton(Type mixinType, ReflectedObject targetClassDefinition)
 {
     return(targetClassDefinition == null ? null : targetClassDefinition.CallMethod("GetMixinByConfiguredType", mixinType));
 }
Exemplo n.º 10
0
        public override ITypeDiscoveryService GetTypeDiscoveryService()
        {
            var type = RemotionAssembly.GetType("Remotion.Reflection.TypeDiscovery.ContextAwareTypeDiscoveryUtility", true);

            return(ReflectedObject.CallMethod(type, "GetTypeDiscoveryService").To <ITypeDiscoveryService>());
        }
Exemplo n.º 11
0
 private ReflectedObject GetMixinDefiniton(Type mixinType, ReflectedObject targetClassDefinition)
 {
     return targetClassDefinition == null ? null : targetClassDefinition.CallMethod ("GetMixinByConfiguredType", mixinType);
 }
Exemplo n.º 12
0
        public void CallMethod_ExistingMethod_Void()
        {
            // TargetDoSomething has method: public void DoSomething()
              var reflectedObject = new ReflectedObject (new TargetDoSomething());
              var output = reflectedObject.CallMethod ("DoSomething");

              Assert.That (output, Is.Null);
        }
Exemplo n.º 13
0
        public void CallMethod_ExistingMethod()
        {
            var reflectedObject = new ReflectedObject ("stringContent");
              var output = reflectedObject.CallMethod ("IndexOf", 't');

              Assert.That (output.To<int>(), Is.EqualTo (1));
        }
Exemplo n.º 14
0
 public void CallMethod_NonExistingMethod()
 {
     var reflectedObject = new ReflectedObject ("stringContent");
       try
       {
     reflectedObject.CallMethod ("nonExistingMethod");
     Assert.Fail ("expected exception not thrown");
       }
       catch (MissingMethodException missingMethodException)
       {
     Assert.That (missingMethodException.Message, Is.EqualTo ("Method 'nonExistingMethod' not found on type 'System.String'."));
       }
 }