예제 #1
0
        public void CanActivateVC_Through_Activator()
        {
            lock (TestOrderingLock.Lock)
            {
                var services = new ServiceCollection();
                var fakefs   = new InMemoryFileProvider();
                fakefs.AddFile("viewComponents/test.os", "Функция ОбработкаВызова() КонецФункции");
                services.AddSingleton <IFileProvider>(fakefs);

                var serviceProvider = services.BuildServiceProvider();

                var cp = new ScriptedViewComponentFeatureProvider();
                cp.Engine             = new ScriptingEngine();
                cp.Engine.Environment = new RuntimeEnvironment();
                cp.ScriptsProvider    = serviceProvider.GetService <IFileProvider>();

                var feature = new ViewComponentFeature();
                var pm      = new ApplicationPartManager();
                pm.ApplicationParts.Add(new AssemblyPart(Assembly.GetExecutingAssembly()));
                pm.FeatureProviders.Add(cp);
                pm.PopulateFeature(feature);

                var descriptorProvider = new DefaultViewComponentDescriptorProvider(pm);
                var activator          = new OscriptViewComponentActivator();
                var descriptor         = descriptorProvider.GetViewComponents().First();
                var context            = new ViewComponentContext();
                context.ViewComponentDescriptor = descriptor;
                var result = activator.Create(context);

                Assert.IsType <ScriptedViewComponent>(result);
            }
        }
        public void CanIgnoreModulesWithoutInvokator()
        {
            lock (TestOrderingLock.Lock)
            {
                var services = new ServiceCollection();
                var fakefs   = new InMemoryFileProvider();
                fakefs.AddFile("viewComponents/test.os", "Функция ДругаяНоНеОбработкаВызова() КонецФункции");
                services.AddSingleton <IFileProvider>(fakefs);

                var serviceProvider = services.BuildServiceProvider();

                var cp = new ScriptedViewComponentFeatureProvider();
                cp.Runtime         = MakeRuntime();
                cp.ScriptsProvider = serviceProvider.GetService <IFileProvider>();

                var feature = new ViewComponentFeature();
                cp.PopulateFeature(new ApplicationPart[0], feature);

                Assert.Equal(0, feature.ViewComponents.Count);
            }
        }
예제 #3
0
        public void CanPopulateViewComponentFeature()
        {
            lock (TestOrderingLock.Lock)
            {
                var services = new ServiceCollection();
                var fakefs   = new InMemoryFileProvider();
                fakefs.AddFile("viewComponents/test.os", "Функция ОбработкаВызова() КонецФункции");
                services.AddSingleton <IFileProvider>(fakefs);

                var serviceProvider = services.BuildServiceProvider();

                var cp = new ScriptedViewComponentFeatureProvider();
                cp.Engine             = new ScriptingEngine();
                cp.Engine.Environment = new RuntimeEnvironment();
                cp.ScriptsProvider    = serviceProvider.GetService <IFileProvider>();

                var feature = new ViewComponentFeature();
                cp.PopulateFeature(new ApplicationPart[0], feature);

                Assert.Equal(1, feature.ViewComponents.Count);
                Assert.Equal("testViewComponent", feature.ViewComponents[0].Name);
            }
        }