Esempio n. 1
0
        public void TestWriteReadStream()
        {
            EventJournal journal = EventJournal.Open("test");

            journal.Write("name123", 1, EventBatch.Of("type1", "type1_instance1"));
            journal.Write("name456", 1, EventBatch.Of("type2", "type2_instance1"));
            journal.Write("name123", 2, EventBatch.Of("type1-1", "type1-1_instance1"));
            journal.Write("name123", 3, EventBatch.Of("type1-2", "type1-2_instance1"));
            journal.Write("name456", 2, EventBatch.Of("type2-1", "type2-1_instance1"));

            EventStreamReader streamReader = journal.StreamReader();

            EventStream eventStream123 = streamReader.StreamFor("name123");

            Assert.AreEqual(3, eventStream123.StreamVersion);
            Assert.AreEqual(3, eventStream123.Stream.Count);
            Assert.AreEqual(new EventValue("name123", 1, "type1", "type1_instance1", ""), eventStream123.Stream[0]);
            Assert.AreEqual(new EventValue("name123", 2, "type1-1", "type1-1_instance1", ""), eventStream123.Stream[1]);
            Assert.AreEqual(new EventValue("name123", 3, "type1-2", "type1-2_instance1", ""), eventStream123.Stream[2]);

            EventStream eventStream456 = streamReader.StreamFor("name456");

            Assert.AreEqual(2, eventStream456.StreamVersion);
            Assert.AreEqual(2, eventStream456.Stream.Count);
            Assert.AreEqual(new EventValue("name456", 1, "type2", "type2_instance1", ""), eventStream456.Stream[0]);
            Assert.AreEqual(new EventValue("name456", 2, "type2-1", "type2-1_instance1", ""), eventStream456.Stream[1]);

            journal.Close();
        }
Esempio n. 2
0
        public void TestWriteReadStreamSnapshot()
        {
            EventJournal journal = EventJournal.Open("test");

            journal.Write("name123", 1, "type1", "type1_instance1", "SNAPSHOT123-1");
            journal.Write("name456", 1, "type2", "type2_instance1", "SNAPSHOT456-1");
            journal.Write("name123", 2, "type1-1", "type1-1_instance1", "SNAPSHOT123-2");
            journal.Write("name123", 3, "type1-2", "type1-2_instance1");
            journal.Write("name456", 2, "type2-1", "type2-1_instance1", "SNAPSHOT456-2");

            EventStreamReader streamReader = journal.StreamReader();

            EventStream eventStream123 = streamReader.StreamFor("name123");

            Assert.AreEqual("name123", eventStream123.StreamName);
            Assert.AreEqual(3, eventStream123.StreamVersion);
            Assert.AreEqual(2, eventStream123.Stream.Count);
            Assert.AreEqual("SNAPSHOT123-2", eventStream123.Snapshot);
            Assert.AreEqual(new EventValue("name123", 2, "type1-1", "type1-1_instance1", "SNAPSHOT123-2"), eventStream123.Stream[0]);
            Assert.AreEqual(new EventValue("name123", 3, "type1-2", "type1-2_instance1", ""), eventStream123.Stream[1]);

            EventStream eventStream456 = streamReader.StreamFor("name456");

            Assert.AreEqual("name456", eventStream456.StreamName);
            Assert.AreEqual(2, eventStream456.StreamVersion);
            Assert.AreEqual(1, eventStream456.Stream.Count);
            Assert.AreEqual("SNAPSHOT456-2", eventStream456.Snapshot);
            Assert.AreEqual(new EventValue("name456", 2, "type2-1", "type2-1_instance1", "SNAPSHOT456-2"), eventStream456.Stream[0]);

            journal.Close();
        }