Example #1
0
        public void Mapping_Handed_Processor_Object_Sets_Processor_Property()
        {
            object processor             = new ViewInjectionProcessor();
            ViewProcessorMapping mapping = new ViewProcessorMapping(MATCHER, processor);

            Assert.That(mapping.Processor, Is.EqualTo(processor));
        }
Example #2
0
        public void Mapping_Handed_Processor_Class_Leaves_Processor_Null()
        {
            Type processorClass          = typeof(ViewInjectionProcessor);
            ViewProcessorMapping mapping = new ViewProcessorMapping(MATCHER, processorClass);

            Assert.That(mapping.Processor, Is.Null);
        }
Example #3
0
        public void Mapping_Handed_Processor_Class_Sets_ProcessorClass_Property()
        {
            Type processorClass          = typeof(ViewInjectionProcessor);
            ViewProcessorMapping mapping = new ViewProcessorMapping(MATCHER, processorClass);

            Assert.That(mapping.ProcessorClass, Is.EqualTo(processorClass));
        }
Example #4
0
        public void RunAllUnprocessors_Runs_All_Unprocessors_For_All_Views()
        {
            TrackingProcessor trackingProcessor2 = new TrackingProcessor();

            SupportView view = new SupportView();
            ObjectWhichExtendsSupportView viewA = new ObjectWhichExtendsSupportView();

            ViewProcessorMapping mapping  = new ViewProcessorMapping(new TypeMatcher().AllOf(view.GetType()).CreateTypeFilter(), trackingProcessor);
            ViewProcessorMapping mappingA = new ViewProcessorMapping(new TypeMatcher().AllOf(viewA.GetType()).CreateTypeFilter(), trackingProcessor2);

            viewProcessorFactory.RunProcessors(view, view.GetType(), new ViewProcessorMapping[1] {
                mapping
            });
            viewProcessorFactory.RunProcessors(viewA, viewA.GetType(), new ViewProcessorMapping[2] {
                mapping, mappingA
            });

            viewProcessorFactory.RunAllUnprocessors();

            Assert.That(trackingProcessor.UnprocessedViews, Is.EquivalentTo(new object[2] {
                view, viewA
            }), "trackingProcessor unprocessed all views");
            Assert.That(trackingProcessor2.UnprocessedViews, Is.EquivalentTo(new object[1] {
                viewA
            }), "trackingProcessor2 unprocessed all views");
        }
        /*============================================================================*/
        /* Private Functions                                                          */
        /*============================================================================*/

        private ViewProcessorMapping CreateMapping(object processor)
        {
            ViewProcessorMapping mapping = new ViewProcessorMapping(_matcher, processor);

            _handler.AddMapping(mapping);
            _mappings[mapping.Processor == null ? mapping.ProcessorClass : mapping.Processor] = mapping;
            if (_logger != null)
            {
                _logger.Debug("{0} mapped to {1}", _matcher, mapping);
            }
            return(mapping);
        }
Example #6
0
        public void Mapping_Remembers_Matcher()
        {
            ViewProcessorMapping mapping = new ViewProcessorMapping(MATCHER, typeof(ViewInjectionProcessor));

            Assert.That(mapping.Matcher, Is.EqualTo(MATCHER));
        }