[Ignore] // TODO fix race condition public void ConcurrentAppendsEntriesToFlatFileWhenUsingAsync() { AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory); const int TimesRepeated = 50; const int NumberOfEntries = 100; for (int repeat = 0; repeat < TimesRepeated; repeat++) { this.fileName = Path.ChangeExtension(Guid.NewGuid().ToString("N"), ".log"); try { using (var sink = new FlatFileSink(this.fileName, new SimpleMessageFormatter(), isAsync: true)) { Parallel.For(0, NumberOfEntries, i => sink.OnNext(EventEntryTestHelper.Create(formattedMessage: "|" + i))); sink.FlushAsync().Wait(); } var entriesStr = ReadFileWithoutLock(this.fileName); var entries = entriesStr.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual <int>(NumberOfEntries, entries.Length, this.fileName + "|" + entries.Length + " " + entriesStr); } finally { if (File.Exists(this.fileName)) { File.Delete(this.fileName); } } } }
[Ignore] // TODO fix race condition public void ConcurrentAppendsEntriesToFlatFileWhenUsingAsync() { sink = new FlatFileSink(this.fileName, new SimpleMessageFormatter(), isAsync: true); const int NumberOfEntries = 100; Parallel.For(0, NumberOfEntries, i => sink.OnNext(EventEntryTestHelper.Create(formattedMessage: "|" + i))); sink.FlushAsync().Wait(); var entries = ReadFileWithoutLock(this.fileName).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual <int>(NumberOfEntries, entries.Length); for (int i = 0; i < NumberOfEntries; i++) { CollectionAssert.Contains(entries, i.ToString()); } }
public void ConcurrentAppendsEntriesToFlatFileWhenUsingAsync() { AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory); const int TimesRepeated = 50; const int NumberOfEntries = 100; for (int repeat = 0; repeat < TimesRepeated; repeat++) { this.fileName = Path.ChangeExtension(Guid.NewGuid().ToString("N"), ".log"); try { using (var sink = new FlatFileSink(this.fileName, isAsync: true)) { Parallel.For(0, NumberOfEntries, i => sink.OnNext("|" + i)); sink.FlushAsync().Wait(); } var entriesStr = ReadFileWithoutLock(this.fileName); var entries = entriesStr.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual<int>(NumberOfEntries, entries.Length, this.fileName + "|" + entries.Length + " " + entriesStr); } finally { if (File.Exists(this.fileName)) File.Delete(this.fileName); } } }
public void ConcurrentAppendsEntriesToFlatFileWhenUsingAsync() { sink = new FlatFileSink(this.fileName, isAsync: true); const int NumberOfEntries = 100; Parallel.For(0, NumberOfEntries, i => sink.OnNext("|" + i)); sink.FlushAsync().Wait(); var entries = ReadFileWithoutLock(this.fileName).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual<int>(NumberOfEntries, entries.Length); for (int i = 0; i < NumberOfEntries; i++) { CollectionAssert.Contains(entries, i.ToString()); } }