public void TestOpenBeforeCreate() { ILogSource logSource = null; try { string fileName = PathEx.GetTempFileName(); if (File.Exists(fileName)) { File.Delete(fileName); } new Action(() => logSource = Create(fileName)).Should().NotThrow(); logSource.Property(x => x.GetProperty(Properties.PercentageProcessed)).ShouldAfter(TimeSpan.FromSeconds(5)).Be(Percentage.HundredPercent); logSource.Property(x => x.GetProperty(Properties.EmptyReason)).ShouldAfter(TimeSpan.FromSeconds(5)).NotBeNull("Because the specified file doesn't exist"); File.WriteAllText(fileName, "Hello World!"); logSource.Property(x => x.GetProperty(Properties.EmptyReason)).ShouldAfter(TimeSpan.FromSeconds(5)).Be(null, "Because the file has been created now"); logSource.Property(x => x.GetProperty(Properties.LogEntryCount)).ShouldAfter(TimeSpan.FromSeconds(5)).Be(1, "Because one line was written to the file"); var entry = logSource.GetEntry(0); entry.Index.Should().Be(0); entry.RawContent.Should().Be("Hello World!"); } finally { logSource?.Dispose(); } }