Example #1
0
        public void SqlCommandStoreWriteReadEntries(SqlSettings settings)
        {
            var config = new EngineConfiguration();

            config.SqlSettings = settings;
            settings.TableName = "test-" + Guid.NewGuid();
            var commandStore = new SqlCommandStore(config);

            commandStore.Initialize();
            var formatter = new BinaryFormatter();
            var writer    = new SqlJournalWriter(formatter, commandStore);

            writer.Write(JournalEntry.Create(1UL, DateTime.Now, new ModelCreated(typeof(TestModel))));
            writer.Write(JournalEntry.Create(2UL, DateTime.Now.AddSeconds(1), new AppendNumberCommand(42)));
            writer.Write(JournalEntry.Create(3UL, DateTime.Now.AddSeconds(2), new AppendNumberCommand(64)));

            foreach (var entry in commandStore.GetJournalEntriesFrom(1))
            {
                Trace.WriteLine(entry);
            }
            writer.Dispose();
        }
Example #2
0
        public void MsSqlCommandStoreWriteReadEntries()
        {
            var config   = new EngineConfiguration();
            var settings = config.SqlSettings;

            settings.ConnectionString = "Data Source=.;Initial Catalog=fish;Integrated Security=True";
            settings.ProviderName     = "System.Data.SqlClient";
            settings.TableName        = "[test-" + Guid.NewGuid() + "]";
            var commandStore = new SqlCommandStore(config);

            commandStore.Initialize();
            var formatter = new BinaryFormatter();
            var writer    = new SqlJournalWriter(formatter, commandStore);

            writer.Write(JournalEntry.Create(1UL, DateTime.Now, new ModelCreated(typeof(TestModel))));
            writer.Write(JournalEntry.Create(2UL, DateTime.Now.AddSeconds(1), new AppendNumberCommand(42)));
            writer.Write(JournalEntry.Create(3UL, DateTime.Now.AddSeconds(2), new AppendNumberCommand(64)));

            foreach (var entry in commandStore.GetJournalEntriesFrom(1))
            {
                Trace.WriteLine(entry);
            }
            writer.Dispose();
        }
Example #3
0
        public void TruncateJournal(SqlSettings settings)
        {
            var config = new EngineConfiguration();

            config.SqlSettings = settings;
            settings.TableName = "test-" + Guid.NewGuid();
            var commandStore = new SqlCommandStore(config);

            commandStore.Initialize();
            var formatter = new BinaryFormatter();
            var writer    = new SqlJournalWriter(formatter, commandStore);

            Enumerable.Range(1, 50).ToList().ForEach(i =>
            {
                writer.Write(JournalEntry.Create((ulong)i, DateTime.Now.AddSeconds(i), new AppendNumberCommand(i)));
            });
            writer.Dispose();
            commandStore.Truncate(40);
            Assert.AreEqual(10, commandStore.CommandEntries().Count());
        }