Пример #1
0
        public void Build_PostProcessing_Test()
        {
            var postProcessorConfig = Substitute.For <PostProcessorConfig>();

            var processor = ProcessorFactory.Build(postProcessorConfig);

            Assert.AreEqual(1, processor.PostProcessActions.Length);
        }
Пример #2
0
        public void Build_EmptyPluginExceptionTest()
        {
            var empty = new object();
            var ex    = Assert.ThrowsException <ArgumentException>(() =>
            {
                ProcessorFactory.Build(empty);
            });

            Assert.AreEqual($"The plugin object \"{empty.ToString()}\" does not have any PreProcessing or ElementProcessing or PostProcessing attribute.", ex.Message);
        }
Пример #3
0
        public void Build_ElementProcessing_Test()
        {
            var paragraph = new Paragraph();
            var elementProcessingConfig = Substitute.For <ElementProcessorConfig>();

            var processor = ProcessorFactory.Build(elementProcessingConfig);

            Assert.AreEqual(
                1,
                processor.ElementProcessingActions[typeof(Paragraph)].Length
                );
        }
Пример #4
0
        public void Build_PostProcessing_InvalidTest()
        {
            var postProcessorConfigs = new object[]
            {
                new InvalidPostProcessorConfig1(),
                new InvalidPostProcessorConfig2()
            };

            foreach (var postProcessorConfig in postProcessorConfigs)
            {
                Assert.ThrowsException <ArgumentException>(() =>
                                                           ProcessorFactory.Build(postProcessorConfig));
            }
        }
Пример #5
0
        public void Build_PreProcessing_InvalidTest()
        {
            var preProcessorConfigs = new object[]
            {
                Substitute.For <InvalidPreProcessorConfig1>(),
                Substitute.For <InvalidPreProcessorConfig2>()
            };

            foreach (var preProcessorConfig in preProcessorConfigs)
            {
                Assert.ThrowsException <ArgumentException>(() =>
                                                           ProcessorFactory.Build(preProcessorConfig));
            }
        }
Пример #6
0
        public void Build_ElementProcessing_InvalidTest()
        {
            object[] processorConfigs = new object[]
            {
                new InvalidElementProcessorConfig1(),
                new InvalidElementProcessorConfig2(),
                new InvalidElementProcessorConfig3(),
                new InvalidElementProcessorConfig4()
            };

            foreach (object processorConfig in processorConfigs)
            {
                Assert.ThrowsException <ArgumentException>(
                    () => ProcessorFactory.Build(processorConfig)
                    );
            }
        }
Пример #7
0
        public void Build_MultipleTest()
        {
            var postProcessorConfigs = new object[]
            {
                new PreProcessorConfig(),
                new PreProcessorConfig(),
                new ElementProcessorConfig(),
                new ElementProcessorConfig(),
                new PostProcessorConfig(),
                new PostProcessorConfig(),
            };

            var processor = ProcessorFactory.Build(postProcessorConfigs);

            Assert.AreEqual(2, processor.PreProcessActions.Length);
            Assert.AreEqual(2, processor.PostProcessActions.Length);

            var pActions = processor.ElementProcessingActions[typeof(Paragraph)];

            Assert.AreEqual(2, pActions.Length);
        }