public void should_add_skipped_automap_types_to_result()
        {
            var despatcher = Mock <IDiagnosticMessageDespatcher> .Create();

            var logger = new DefaultDiagnosticLogger(despatcher);

            logger.AutomappingSkippedType(typeof(object), "reason");
            logger.Flush();

            DiagnosticResults result = null;

            despatcher.AssertWasCalled(x => x.Publish(Arg <DiagnosticResults> .Is.Anything),
                                       c => c.Callback <DiagnosticResults>(x =>
            {
                result = x;
                return(true);
            }));

            result.AutomappingSkippedTypes
            .ShouldContain(new SkippedAutomappingType
            {
                Type   = typeof(object),
                Reason = "reason"
            });
        }
        public void should_not_flush_messages_to_dispatcher_when_no_messages_logged()
        {
            var dispatcher = A.Fake <IDiagnosticMessageDispatcher>();
            var logger     = new DefaultDiagnosticLogger(dispatcher);

            logger.Flush();

            A.CallTo(() => dispatcher.Publish(A <DiagnosticResults> ._)).MustNotHaveHappened();
        }
        public void should_flush_messages_to_dispatcher()
        {
            var dispatcher = A.Fake <IDiagnosticMessageDispatcher>();
            var logger     = new DefaultDiagnosticLogger(dispatcher);

            logger.FluentMappingDiscovered(typeof(SomeClassMap));
            logger.Flush();

            A.CallTo(() => dispatcher.Publish(A <DiagnosticResults> ._)).MustHaveHappened();
        }
        public void should_not_flush_messages_to_despatcher_when_no_messages_logged()
        {
            var despatcher = Mock <IDiagnosticMessageDespatcher> .Create();

            var logger = new DefaultDiagnosticLogger(despatcher);

            logger.Flush();

            despatcher.AssertWasNotCalled(x => x.Publish(Arg <DiagnosticResults> .Is.Anything));
        }
        public void should_flush_messages_to_despatcher()
        {
            var despatcher = Mock <IDiagnosticMessageDespatcher> .Create();

            var logger = new DefaultDiagnosticLogger(despatcher);

            logger.FluentMappingDiscovered(typeof(SomeClassMap));
            logger.Flush();

            despatcher.AssertWasCalled(x => x.Publish(Arg <DiagnosticResults> .Is.Anything));
        }
        public void should_add_conventions_to_result()
        {
            var dispatcher = A.Fake <IDiagnosticMessageDispatcher>();
            var logger     = new DefaultDiagnosticLogger(dispatcher);

            DiagnosticResults result = null;

            A.CallTo(() => dispatcher.Publish(A <DiagnosticResults> ._))
            .Invokes(a => { result = (DiagnosticResults)a.Arguments.First(); });

            logger.ConventionDiscovered(typeof(SomeConvention));
            logger.Flush();

            result.Conventions.ShouldContain(typeof(SomeConvention));
        }
        public void should_add_automapping_candidates()
        {
            var dispatcher = A.Fake <IDiagnosticMessageDispatcher>();
            var logger     = new DefaultDiagnosticLogger(dispatcher);

            DiagnosticResults result = null;

            A.CallTo(() => dispatcher.Publish(A <DiagnosticResults> ._))
            .Invokes(a => { result = (DiagnosticResults)a.Arguments.First(); });

            logger.AutomappingCandidateTypes(new[] { typeof(object) });
            logger.Flush();

            result.AutomappingCandidateTypes
            .ShouldContain(typeof(object));
        }
        public void should_add_automapping_type_with_begin()
        {
            var dispatcher = A.Fake <IDiagnosticMessageDispatcher>();
            var logger     = new DefaultDiagnosticLogger(dispatcher);

            DiagnosticResults result = null;

            A.CallTo(() => dispatcher.Publish(A <DiagnosticResults> ._))
            .Invokes(a => { result = (DiagnosticResults)a.Arguments.First(); });

            logger.BeginAutomappingType(typeof(object));
            logger.Flush();

            result.AutomappedTypes
            .Select(x => x.Type)
            .ShouldContain(typeof(object));
        }
        public void should_add_scanned_convention_sources_to_result()
        {
            var dispatcher = A.Fake <IDiagnosticMessageDispatcher> ();
            var logger     = new DefaultDiagnosticLogger(dispatcher);

            DiagnosticResults result = null;

            A.CallTo(() => dispatcher.Publish(A <DiagnosticResults> ._))
            .Invokes(a => { result = (DiagnosticResults)a.Arguments.First(); });

            logger.LoadedConventionsFromSource(new StubTypeSource());
            logger.Flush();

            result.ScannedSources
            .Where(x => x.Phase == ScanPhase.Conventions)
            .Select(x => x.Identifier)
            .ShouldContain("StubTypeSource");
        }
        public void should_add_skipped_automap_types_to_result()
        {
            var dispatcher = A.Fake <IDiagnosticMessageDispatcher>();
            var logger     = new DefaultDiagnosticLogger(dispatcher);

            DiagnosticResults result = null;

            A.CallTo(() => dispatcher.Publish(A <DiagnosticResults> ._))
            .Invokes(a => { result = (DiagnosticResults)a.Arguments.First(); });

            logger.AutomappingSkippedType(typeof(object), "reason");
            logger.Flush();

            result.AutomappingSkippedTypes
            .ShouldContain(new SkippedAutomappingType
            {
                Type   = typeof(object),
                Reason = "reason"
            });
        }
        public void should_add_conventions_to_result()
        {
            var despatcher = Mock <IDiagnosticMessageDespatcher> .Create();

            var logger = new DefaultDiagnosticLogger(despatcher);

            logger.ConventionDiscovered(typeof(SomeConvention));
            logger.Flush();

            DiagnosticResults result = null;

            despatcher.AssertWasCalled(x => x.Publish(Arg <DiagnosticResults> .Is.Anything),
                                       c => c.Callback <DiagnosticResults>(x =>
            {
                result = x;
                return(true);
            }));

            result.Conventions.ShouldContain(typeof(SomeConvention));
        }
        public void should_add_automapping_candidates()
        {
            var despatcher = Mock <IDiagnosticMessageDespatcher> .Create();

            var logger = new DefaultDiagnosticLogger(despatcher);

            logger.AutomappingCandidateTypes(new[] { typeof(object) });
            logger.Flush();

            DiagnosticResults result = null;

            despatcher.AssertWasCalled(x => x.Publish(Arg <DiagnosticResults> .Is.Anything),
                                       c => c.Callback <DiagnosticResults>(x =>
            {
                result = x;
                return(true);
            }));

            result.AutomappingCandidateTypes
            .ShouldContain(typeof(object));
        }
        public void should_add_automapping_type_with_begin()
        {
            var despatcher = Mock <IDiagnosticMessageDespatcher> .Create();

            var logger = new DefaultDiagnosticLogger(despatcher);

            logger.BeginAutomappingType(typeof(object));
            logger.Flush();

            DiagnosticResults result = null;

            despatcher.AssertWasCalled(x => x.Publish(Arg <DiagnosticResults> .Is.Anything),
                                       c => c.Callback <DiagnosticResults>(x =>
            {
                result = x;
                return(true);
            }));

            result.AutomappedTypes
            .Select(x => x.Type)
            .ShouldContain(typeof(object));
        }
        public void should_add_scanned_fluent_mapping_sources_to_result()
        {
            var despatcher = Mock <IDiagnosticMessageDespatcher> .Create();

            var logger = new DefaultDiagnosticLogger(despatcher);

            logger.LoadedFluentMappingsFromSource(new StubTypeSource());
            logger.Flush();

            DiagnosticResults result = null;

            despatcher.AssertWasCalled(x => x.Publish(Arg <DiagnosticResults> .Is.Anything),
                                       c => c.Callback <DiagnosticResults>(x =>
            {
                result = x;
                return(true);
            }));

            result.ScannedSources
            .Where(x => x.Phase == ScanPhase.FluentMappings)
            .Select(x => x.Identifier)
            .ShouldContain("StubTypeSource");
        }