public void WriteEventFires() { foreach (Journal journal in GetTestJournals()) { bool?entryFlushedFired = false; bool?queueEmptyFired = false; journal.EntryFlushed += (o, a) => entryFlushedFired = true; journal.QueueEmpty += (o, a) => queueEmptyFired = true; DataReplicationTestClass value = GetDataInstance(); IEnumerable <JournalEntry> entries = journal.Enqueue(value); foreach (JournalEntry entry in entries) { Console.WriteLine("TypeId={0}, PropertyId={1}, TypeName={2}, PropertyName={3}, Value={4}", entry.TypeId, entry.PropertyId, journal.GetTypeName(entry.TypeId), journal.GetPropertyName(entry.PropertyId), entry.Value); } if (Exec.TakesTooLong(() => { Exec.SleepUntil(() => queueEmptyFired.Value); }, 5000)) { Expect.Fail("took too long"); } Expect.IsTrue(entryFlushedFired.Value); Expect.IsTrue(queueEmptyFired.Value); Message.PrintLine("journal directory {0}", ConsoleColor.Cyan, journal.JournalDirectory.FullName); Thread.Sleep(3000); } }
public void EncryptionJournalGetsLatestPropertyValue() { AutoResetEvent blocker = new AutoResetEvent(false); DataReplicationTestClass value = GetRandomDataInstance(); Journal journal = GetEncryptionJournal <Journal>(); bool? checkedJournal = false; journal.Enqueue(value, (jes) => jes.Each(je => { checkedJournal = true; Expect.AreSame(journal, je.Journal); blocker.Set(); })); if (!blocker.WaitOne(15000)) { Warn("Inconclusive, blocker was not set"); } Expect.IsTrue(checkedJournal.Value); string newAddress = "Updated " + 8.RandomLetters(); value.Address = newAddress; journal.Enqueue(value, (jes) => { DataReplicationTestClass check = journal.LoadInstance <DataReplicationTestClass>(value.Id); Expect.AreEqual(newAddress, check.Address); blocker.Set(); }); if (!blocker.WaitOne(15000)) { Warn("Inconclusive, blocker was not set"); } }
public void CanWriteEntries() { foreach (Journal journal in GetTestJournals()) { DataReplicationTestClass value = GetDataInstance(); IEnumerable <JournalEntry> entries = journal.Enqueue(value); WriteToConsole(journal, entries); value.Address = "A new Address"; entries = journal.Enqueue(value); WriteToConsole(journal, entries); Message.PrintLine("journal directory {0}", ConsoleColor.Cyan, journal.JournalDirectory.FullName); Thread.Sleep(3000); } }
public void CompressionJournalGetsLatestPropertyValue() { Log.DebugOut = true; AutoResetEvent blocker = new AutoResetEvent(false); DataReplicationTestClass value = GetRandomDataInstance(); Journal journal = GetCompressionJournal <Journal>(); journal.Logger = new ConsoleLogger(); bool?checkedJournal = false; journal.Enqueue(value, (jes) => jes.Each(je => { Message.PrintLine("Fully flushed called", ConsoleColor.DarkBlue); checkedJournal = true; Expect.AreSame(journal, je.Journal); blocker.Set(); })); for (int i = 0; i < 100; i++) { Thread.Sleep(30); Message.PrintLine("QueueLength={0}", ConsoleColor.Cyan, journal.QueueLength.ToString()); Message.PrintLine("Flushed status: {0}", ConsoleColor.Yellow, journal.QueueFlusher.ThreadState.ToString()); } if (!blocker.WaitOne(15000)) { Warn("Inconclusive, blocker was not set"); } checkedJournal.Value.IsTrue(); string newAddress = "Updated " + 8.RandomLetters(); value.Address = newAddress; journal.Enqueue(value, (jes) => { DataReplicationTestClass check = journal.LoadInstance <DataReplicationTestClass>(value.Id); Expect.AreEqual(newAddress, check.Address); OutLine(check.Address); blocker.Set(); }); if (!blocker.WaitOne(15000)) { Warn("Inconclusive, blocker was not set"); } }
private static void DoReadTest(Journal journal) { DataReplicationTestClass value1 = GetRandomDataInstance(); HashSet <DataReplicationTestClass> retrieved = new HashSet <DataReplicationTestClass>(); List <JournalEntry> entries = new List <JournalEntry>(); AutoResetEvent blocker = new AutoResetEvent(false); bool?fullyFlushed = false; entries.AddRange(journal.Enqueue(value1, (je) => { fullyFlushed = true; blocker.Set(); })); blocker.WaitOne(60000); DataReplicationTestClass check = journal.LoadInstance <DataReplicationTestClass>(value1.Id); Expect.IsNotNull(check); Expect.IsTrue(fullyFlushed.Value); Expect.AreEqual(value1.FirstName, check.FirstName); Expect.AreEqual(value1.LastName, check.LastName); Expect.AreEqual(value1.Address, check.Address); Thread.Sleep(3000); }