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); }
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 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(); }
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()); }
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(); }