public void RollbackMarkerIsWrittenOnRollback()
        {
            //Arrange
            var config = EngineConfiguration.Create().ForIsolatedTest();
            var store = new InMemoryCommandStore(config);
            store.Initialize();
            var target = new JournalAppender(1, new StreamJournalWriter(config, store.CreateJournalWriterStream));

            var command = new ACommand();
            command.Timestamp = DateTime.Now;
            target.Append(command);
            target.Append(command);

            //Act
            target.AppendRollbackMarker();

            //Assert
            Assert.AreEqual(3, store.GetJournalEntries().Count());
            Assert.AreEqual(1, store.GetJournalEntries().OfType<JournalEntry<RollbackMarker>>().Count());
            Assert.IsTrue(store.GetJournalEntries().Last() is JournalEntry<RollbackMarker>);
        }
Exemple #2
0
        public void RollbackMarkerIsWrittenOnRollback()
        {
            //Arrange
            var config = EngineConfiguration.Create().ForIsolatedTest();
            var store  = new InMemoryCommandStore(config);

            store.Initialize();
            var target = new JournalAppender(1, new StreamJournalWriter(config, store.CreateJournalWriterStream));

            var command = new ACommand();

            command.Timestamp = DateTime.Now;
            target.Append(command);
            target.Append(command);

            //Act
            target.AppendRollbackMarker();

            //Assert
            Assert.AreEqual(3, store.GetJournalEntries().Count());
            Assert.AreEqual(1, store.GetJournalEntries().OfType <JournalEntry <RollbackMarker> >().Count());
            Assert.IsTrue(store.GetJournalEntries().Last() is JournalEntry <RollbackMarker>);
        }
        public void Timestamp_is_copied_to_journal_entry()
        {
            JournalEntry entry = null;

            var fake = A.Fake <IJournalWriter>();

            A.CallTo(() => fake.Write(A <JournalEntry> ._))
            .Invokes((JournalEntry je) =>
            {
                entry = je;
            });

            var command = new SetTimeCommand();

            command.Timestamp = DateTime.Now;
            var target = new JournalAppender(0, fake);

            target.Append(command);

            Assert.IsNotNull(entry);
            Assert.AreEqual(command.Timestamp, entry.Created);
        }
        public void Timestamp_is_copied_to_journal_entry()
        {
            JournalEntry entry = null;

            var fake = A.Fake <IJournalWriter>();

            A.CallTo(() => fake.Write(A <JournalEntry> ._))
            .Invokes((JournalEntry je) =>
            {
                entry = je;
            });

            var before = DateTime.Now;

            ExecutionContext.Begin();
            var command = new SetTimeCommand();
            var target  = new JournalAppender(0, fake);
            var after   = DateTime.Now;

            target.Append(command);

            Assert.IsNotNull(entry);
            Assert.IsTrue(before <= entry.Created && entry.Created <= after);
        }