public void Create_Instance_With_Default_Factory_Works()
        {
            var instance = SourceResolver.CreateInstance(typeof(MyViewA));

            Assert.IsNotNull(instance);
            Assert.AreEqual(typeof(MyViewA), instance.GetType());
        }
        /// <summary>
        /// Creates the <see cref="IModuleConfiguration"/> instance and invokes <see cref="IModuleConfiguration.Initialize"/>.
        /// </summary>
        /// <param name="module">The module</param>
        /// <param name="assembly">The assembly</param>
        public static void Initialize(ModuleInfo module, Assembly assembly)
        {
            if (module == null)
            {
                throw new ArgumentNullException(nameof(module));
            }
            if (assembly == null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }

            var moduleConfigurationType = assembly.GetType(module.ModuleConfigurationFullName);

            if (moduleConfigurationType == null)
            {
                throw new ArgumentException($"Unable to resolve the type for '{module.ModuleConfigurationFullName}'");
            }

            var instance            = SourceResolver.CreateInstance(moduleConfigurationType);
            var moduleConfiguration = instance as IModuleConfiguration;

            if (moduleConfiguration == null)
            {
                throw new ArgumentException($"The module configuration '{module.ModuleConfigurationFullName}' ('{module.ModuleName}') has to implement IModuleConfiguration interface");
            }

            moduleConfiguration.Initialize();
        }
        public void Change_And_Reset_The_Factory()
        {
            var mySourceFactory = new MySourceFactory();

            Assert.AreEqual(false, mySourceFactory.IsCalled);

            SourceResolver.SetFactory(mySourceFactory.CreateInstance);
            var instance = SourceResolver.CreateInstance(typeof(MyViewB));

            Assert.IsNotNull(instance);
            Assert.AreEqual(typeof(MyViewB), instance.GetType());
            Assert.AreEqual(true, mySourceFactory.IsCalled);


            SourceResolver.SetFactoryToDefault();
            mySourceFactory.IsCalled = false;
            var instance2 = SourceResolver.CreateInstance(typeof(MyViewB));

            Assert.IsNotNull(instance2);
            Assert.AreEqual(typeof(MyViewB), instance2.GetType());
            Assert.AreEqual(false, mySourceFactory.IsCalled);
        }