public void get_implied_renderer_type_unknown() { FileTargetBuilder unit = new FileTargetBuilder(); unit.FileName = "file.zzz"; Assert.IsInstanceOf <NullRenderer>(unit.DefaultRenderer); }
public void get_implied_renderer_using_layout() { FileTargetBuilder unit = new FileTargetBuilder(); unit.Layout = "{Timestamp}"; Assert.IsInstanceOf <TextRenderer>(unit.DefaultRenderer); }
public void get_implied_renderer_type_log() { FileTargetBuilder unit = new FileTargetBuilder(); unit.FileName = "file.log"; Assert.IsInstanceOf <TextRenderer>(unit.DefaultRenderer); }
internal FileTarget(FileTargetBuilder builder, IServiceProvider sp) : base(builder) { this.CreateDirectories = builder.CreateDirectories; this.FileName = builder.FileName; this.Mode = builder.Mode; this.RolloverMode = builder.Rollover.Mode; this.RolloverMaxFileSize = builder.Rollover.MaxFileSize; this.RolloverMaxAge = builder.Rollover.MaxAge; this.Renderer = builder.Renderer ?? builder.DefaultRenderer; this.Index = -1; this.baseUri = ((IUriContext)builder).BaseUri; this.fileNamePattern = ParsedLayout.ParseFileName(this.FileName); }
public void should_flush_on_appdomain_close() { // TODO Flushing only happens when target is in a logger, so this test // doesn't work... // When this app domain exits, all file items should have been // written out despite an implicit Flush and even when finalizing AppDomain cd = App; AppDomain appDomain = AppDomain.CreateDomain( "a", cd.Evidence, new AppDomainSetup { ApplicationBase = cd.BaseDirectory, }); // This is done because otherwise filename would have to be captured in a // closure that isn't serializable (and couldn't be marshalled) string fileName = Path.GetTempFileName(); appDomain.SetData("fileName", fileName); CrossAppDomainDelegate d = () => { FileTargetBuilder ft = new FileTargetBuilder { FileName = (string)App.GetData("fileName"), EventBufferSize = 100, // Sufficiently large buffer }; FileTarget fileTarget = (FileTarget)ft.Build(null); fileTarget.Write(CreateEvent()); fileTarget.Write(CreateEvent()); fileTarget.Write(CreateEvent()); // Intentionally not disposing - fileTarget.Dispose(); }; appDomain.DoCallBack(d); AppDomain.Unload(appDomain); Assert.That(File.ReadAllLines(fileName).Length, Is.EqualTo(3), "Should have implicitly flushed file log data when the domain was unloaded: {0}", fileName); }
public void check_default_values() { FileTargetBuilder unit = new FileTargetBuilder(); AssertDefaultValues(unit); }