public void AddExistingModuleThrows()
        {
            var loader = new ModuleLoader(_ => null);

            loader.Add(typeof(object));

            var exception = Record.Exception(() => loader.Add(typeof(object)));

            Assert.IsType <InvalidOperationException>(exception);
        }
        public void AddedModuleIsVisibleInCatalog()
        {
            var loader = new ModuleLoader(_ => null);

            loader.Add(typeof(object));

            Assert.Contains(typeof(object), loader.ModuleTypes);
        }
        public void NullModuleReturnedThrows()
        {
            var loader = new ModuleLoader(_ => null);

            loader.Add(typeof(object));

            var exception = Record.Exception(() => loader.Initialize());

            Assert.IsType <InitializeModuleException>(exception);
        }
        public void InitialiseCalledOnModule()
        {
            var module = new MockModule();

            var loader = new ModuleLoader(_ => module);

            loader.Add(typeof(object));

            loader.Initialize();

            Assert.True(module.InitializeCalled);
        }
        public void InnerErrorInInitialiseRaisesModuleInitialiseException()
        {
            var module = new InvalidModule();

            var loader = new ModuleLoader(_ => module);

            loader.Add(typeof(object));

            var exception = Record.Exception(() => loader.Initialize());

            Assert.IsType <InitializeModuleException>(exception);
            Assert.IsType <InvalidOperationException>(exception.InnerException);
        }
        public void InitialiseTypePassedToCreator()
        {
            var  module = new MockModule();
            Type type   = null;

            IModule Action(Type x)
            {
                type = x;

                return(module);
            }

            var loader = new ModuleLoader(Action);

            loader.Add(typeof(object));

            loader.Initialize();

            Assert.Equal(typeof(object), type);
        }