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), "");
        }
        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);
        }
        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);
        }
Beispiel #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();
        }
        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 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());
        }
Beispiel #7
0
        private static ConventionBuilder GetBuilder()
        {
            var builder = new ConventionBuilder();

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

            return builder;
        }
Beispiel #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);
        }
        public void VerifyExclusionOfCompilerClasses()
        {
            var builder = new ConventionBuilder();

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

            var conventions = builder.Build();

            conventions.Verify();
        }