public void SetUp()
        {
            // Reset static properties
            typeof(Composer.ComposerHost)
            .GetProperty("Current")
            .GetSetMethod(true)
            .Invoke(null, new object[] { null });

            //Reset Handlerbars static state
            Handlebars.Configuration.Helpers.Clear();
            Handlebars.Configuration.BlockHelpers.Clear();


            // Default setup for all required entities
            Composer.ComposerHost host = new Composer.ComposerHost(Assembly.GetExecutingAssembly());

            // Mock AspNetConfigManager
            Mock <IAspNetConfigurationManager> aspNetConfigManagerMock = new Mock <IAspNetConfigurationManager>(MockBehavior.Strict);

            aspNetConfigManagerMock
            .Setup(config => config.Configure(It.IsAny <ILifetimeScope>(), It.IsAny <IViewEngine>(), It.IsAny <MediaTypeFormatter>()));
            host.SetAspNetConfigurationManager(aspNetConfigManagerMock.Object);

            // Mock AssemblyHelper
            var assemblyHelper = new Mock <Composer.AssemblyHelper>();

            assemblyHelper.Setup(helper => helper.SafeLoadAssemblies(It.IsAny <string>()))
            .Returns(() => new _Assembly[0]);
            host.SetAssemblyHelper(assemblyHelper.Object);

            // Mock Composer Environment
            var composerEnvironment = ComposerEnvironmentFactory.Create();

            host.SetComposerEnvironment(composerEnvironment.Object);

            //Add some additionnal dependencies expected to be set by a plugin (what?!)
            var lookupService = new Mock <ILookupService>(MockBehavior.Strict);

            host.Register <ILookupService>(lookupService.Object);
            var currencyProviderMock = new Mock <ICurrencyProvider>(MockBehavior.Strict);

            host.Register <ICurrencyProvider>(currencyProviderMock.Object);
            _composerHost      = host;
            _serviceLocatorMoq = new ServiceLocatorMoq();
        }
示例#2
0
        public void SetUp()
        {
            // Reset static properties
            typeof(Composer.ComposerHost)
            .GetProperty("Current")
            .GetSetMethod(true)
            .Invoke(null, new object[] { null });

            TestPlugin.WasDiscovered = false;

            // Default setup for all required entities
            _composerHost = new Composer.ComposerHost(Assembly.GetExecutingAssembly());

            // Mock AspNetConfigManager
            _aspNetConfigManagerMock = new Mock <IAspNetConfigurationManager>();
            _aspNetConfigManagerMock.Setup(_configureCall);
            _composerHost.SetAspNetConfigurationManager(_aspNetConfigManagerMock.Object);

            // Mock AssemblyHelper
            var assemblyHelper = new Mock <Composer.AssemblyHelper>();

            assemblyHelper.Setup(helper => helper.SafeLoadAssemblies(It.IsAny <string>()))
            .Returns(() => new _Assembly[0]);
            _composerHost.SetAssemblyHelper(assemblyHelper.Object);

            // Mock Composer Environment
            var composerEnvironment = ComposerEnvironmentFactory.Create();

            _composerHost.SetComposerEnvironment(composerEnvironment.Object);

            //Add some additional dependencies expected to be set by a plugin (what?!)
            var lookupService = new Mock <ILookupService>(MockBehavior.Strict);

            _composerHost.Register <ILookupService>(lookupService.Object);
            var currencyProviderMock = new Mock <ICurrencyProvider>(MockBehavior.Strict);

            _composerHost.Register <ICurrencyProvider>(currencyProviderMock.Object);
            _serviceLocatorMoq = new ServiceLocatorMoq();
        }