Exemplo n.º 1
0
        public void UsingNLog()
        {
            var writer = GetTrace();

            LoggingConfiguration config = new LoggingConfiguration();

            TraceTarget target = new TraceTarget();
            target.Layout = "NLOG [${level:uppercase=true}] ${message}";
            config.AddTarget("trace", target);
            config.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, target));

            LogManager.Configuration = config;

            ConventionBuilder.Logger = t => LogManager.GetLogger(t);

            var builder = new ConventionBuilder();
            builder.ScanThisAssembly().For<HandlerConventions>();

            var convention = builder.Build();

            Approvals.VerifyAll(writer
                .ToString()
                .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
                .OrderBy(s => s), "");
        }
Exemplo n.º 2
0
        public void VerifyConventions()
        {
            var builder = new ConventionBuilder();

            builder.ScanThisAssembly()
                .For<ServiceConventions>();

            var conventions = builder.Build();

            var exception = Assert.Throws<ConventionNotFollowedException>(() => conventions.Verify());

            Approvals.Verify(exception.Message);
        }
Exemplo n.º 3
0
        public void CanIncludeCompilerClassesInConvention()
        {
            var builder = new ConventionBuilder();

            builder.ScanThisAssembly()
                .For<Handler2Conventions>();

            var conventions = builder.Build();

            var exception = Assert.Throws<ConventionNotFollowedException>(() => conventions.Verify());

            Approvals.Verify(exception.Message);
        }
Exemplo n.º 4
0
        static Conventions()
        {
            var builder = new ConventionBuilder();

            //foreach (var assm in AssemblySource.Instance)
            builder.ScanThisAssembly()
            .For <AttachmentConventions>()
            .For <ViewModelConventions>()
            .For <ViewConventions>()
            .For <ServiceConventions>()
            ;

            conventions = builder.Build();
        }
Exemplo n.º 5
0
        public void VerifyConventionsToLog()
        {
            var writer = GetTrace();

            var builder = new ConventionBuilder();

            builder.ScanThisAssembly()
                .For<ServiceConventions>();

            var conventions = builder.Build();

            conventions.Verify(true);

            Approvals.Verify(writer.ToString());
        }
        public ConventionManager(Type scanType, Type attachmentConvention, Type viewConvention, Type viewModelConvention)
        {
            this.attachmentConvention = attachmentConvention;
            this.viewConvention = viewConvention;
            this.viewModelConvention = viewModelConvention;

            ConventionBuilder.Logger = PiracRunner.GetLogger;

            var builder = new ConventionBuilder();

            builder.Scan(scanType)
                .For(attachmentConvention)
                .For(viewConvention)
                .For(viewModelConvention);

            conventionManager = builder.Build();

            conventionManager.Verify();
        }
Exemplo n.º 7
0
        public void SimpleLog()
        {
            var writer = GetTrace();

            // Makes sure the internal logger is used.
            ConventionBuilder.Logger = t => new Conventional.Core.Logger();

            var builder = new ConventionBuilder();
            builder.ScanThisAssembly().For<HandlerConventions>();

            var convention = builder.Build();

            Approvals.Verify(new ApprovalTextWriter(writer
                .ToString()
                .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
                .OrderBy(s => s)
                .Write("")),
                new ConfigNamer(),
                Approvals.GetReporter());
        }
Exemplo n.º 8
0
        public void ReturnsEmptyListIfNoConventionFoundVariant()
        {
            var builder = new ConventionBuilder();

            builder.ScanThisAssembly()
                .For<ModelConventions>()
                .For<MadeUpConventions>();

            var conventions = builder.Build();

            var models = conventions.FindAll<MadeUpConventions>(typeof(SomeModel));

            Assert.Empty(models);
        }
Exemplo n.º 9
0
        public void VerifyExclusionOfCompilerClasses()
        {
            var builder = new ConventionBuilder();

            builder.ScanThisAssembly()
                .For<HandlerConventions>();

            var conventions = builder.Build();

            conventions.Verify();
        }