public void AppendsEntriesToFlatFile() { sink = new FlatFileSink(this.fileName, new SimpleMessageFormatter(), false); sink.OnNext(EventEntryTestHelper.Create(formattedMessage: "|1")); sink.OnNext(EventEntryTestHelper.Create(formattedMessage: "|2")); sink.OnNext(EventEntryTestHelper.Create(formattedMessage: "|3")); var entries = ReadFileWithoutLock(this.fileName).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual <int>(3, entries.Length); Assert.AreEqual("1", entries[0]); Assert.AreEqual("2", entries[1]); Assert.AreEqual("3", entries[2]); }
public void AppendsEntriesToFlatFile() { sink = new FlatFileSink(this.fileName, false); sink.OnNext("|1"); sink.OnNext("|2"); sink.OnNext("|3"); var entries = ReadFileWithoutLock(this.fileName).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual <int>(3, entries.Length); Assert.AreEqual("1", entries[0]); Assert.AreEqual("2", entries[1]); Assert.AreEqual("3", entries[2]); }
[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); } } } }
public void CreatesFlatFile() { sink = new FlatFileSink(this.fileName, new SimpleMessageFormatter(), false); sink.OnNext(EventEntryTestHelper.Create(formattedMessage: "|1")); Assert.IsTrue(File.Exists(this.fileName)); var entries = ReadFileWithoutLock(this.fileName).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual <int>(1, entries.Count()); }
public void CreatesFlatFile() { sink = new FlatFileSink(this.fileName, false); sink.OnNext("|1"); Assert.IsTrue(File.Exists(this.fileName)); var entries = ReadFileWithoutLock(this.fileName).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual <int>(1, entries.Count()); }
public void OnNext(EventEntry value) { //Console.WriteLine("OnNext"); if (value != null) { //System.IO.File.AppendAllText(@"D:\bob.txt", "jaime les chats"); var message = value.Payload[0]; Console.WriteLine(message); _sink.OnNext(value); } }
[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 ConcurrentAppendsEntriesToFlatFile() { sink = new FlatFileSink(this.fileName, false); const int NumberOfEntries = 100; Parallel.For(0, NumberOfEntries, i => sink.OnNext("|" + i)); 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 CreatesFlatFile() { sink = new FlatFileSink(this.fileName, false); sink.OnNext("|1"); Assert.IsTrue(File.Exists(this.fileName)); var entries = ReadFileWithoutLock(this.fileName).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual<int>(1, entries.Count()); }
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()); } }
public void AppendsEntriesToFlatFile() { sink = new FlatFileSink(this.fileName, false); sink.OnNext("|1"); sink.OnNext("|2"); sink.OnNext("|3"); var entries = ReadFileWithoutLock(this.fileName).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual<int>(3, entries.Length); Assert.AreEqual("1", entries[0]); Assert.AreEqual("2", entries[1]); Assert.AreEqual("3", entries[2]); }
public void AppendsEntriesToFlatFile() { sink = new FlatFileSink(this.fileName, new SimpleMessageFormatter(), false); sink.OnNext(EventEntryTestHelper.Create(formattedMessage: "|1")); sink.OnNext(EventEntryTestHelper.Create(formattedMessage: "|2")); sink.OnNext(EventEntryTestHelper.Create(formattedMessage: "|3")); var entries = ReadFileWithoutLock(this.fileName).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual<int>(3, entries.Length); Assert.AreEqual("1", entries[0]); Assert.AreEqual("2", entries[1]); Assert.AreEqual("3", entries[2]); }
public void CreatesFlatFile() { sink = new FlatFileSink(this.fileName, new SimpleMessageFormatter(), false); sink.OnNext(EventEntryTestHelper.Create(formattedMessage: "|1")); Assert.IsTrue(File.Exists(this.fileName)); var entries = ReadFileWithoutLock(this.fileName).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual<int>(1, entries.Count()); }
public void ConcurrentAppendsEntriesToFlatFile() { sink = new FlatFileSink(this.fileName, new SimpleMessageFormatter(), false); const int NumberOfEntries = 100; Parallel.For(0, NumberOfEntries, i => sink.OnNext(EventEntryTestHelper.Create(formattedMessage: "|" + i))); 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()); } }