public static void Main(string[] args) { var es = new Eventstore <InMemoryEventRepository>(); var a = new A(); var b = new B(); var c = new C(); es.Record(null, a); es.Record(a.Id, c); es.Record(c.Id, b); EventArchive.Write("myarchive.json", es.Replay()); var events = EventArchive.Read("myarchive.json"); var es2 = new Eventstore <InMemoryEventRepository>(); EventId id = null; events.ToList().ForEach(delegate(IEvent e) { es2.Record(id, e); id = e.Id; }); Console.WriteLine(es2.Replay().ToList().Count); }
public void Store_and_load() { const string FILENAME = nameof(EventArchive_tests) + "_" + nameof(Store_and_load) + ".json"; if (File.Exists(FILENAME)) { File.Delete(FILENAME); } var events = new IEvent[] { new TestEvent { Foo = "a" }, new AnotherTestEvent { Bar = 1 }, new TestEvent { Foo = "b" } }; EventArchive.Write(FILENAME, events); var result = EventArchive.Read(FILENAME).ToArray(); Assert.Equal("a", ((TestEvent)result[0]).Foo); Assert.Equal(1, ((AnotherTestEvent)result[1]).Bar); Assert.Equal("b", ((TestEvent)result[2]).Foo); }
public static void Main(string[] args) { var es = new InMemoryEventstore(); es.Record(new A()); es.Record(new C()); es.Record(new B()); nsimpleeventstore.adapters.EventArchive.Write("myarchive.json", es.Replay().Events); var events = EventArchive.Read("myarchive.json"); var es2 = new InMemoryEventstore(events); Console.WriteLine(es2.Replay().Events.Length); }