public void store_a_bunch_of_events() { var ar = new Account {Id = _id}; var eventsToPersist = new List<object>(); eventsToPersist.Add(new AccountOpened{InitialDeposit = 5,Name = "test"}); var startEventsAt = DateTime.Now.AddYears(-1); for(var i = 0; i< 100; i++) { object @event = null; if(i % 1 == 0) { @event = new Deposit {Amount = i,AccountId = ar.Id,At = startEventsAt.AddDays(i) }; }else { @event = new WithDraw {Amount = i, AccountId = ar.Id, At = startEventsAt.AddDays(i)}; } eventsToPersist.Add(@event); } _eventStore.Persist(ar.Id,eventsToPersist.ToArray()); }
public void Apply(WithDraw withdraw) { _balance -= withdraw.Amount; Activity.Add("on " + withdraw.At.ToShortDateString() + " Withdraw of " + withdraw.Amount + " balance:" + _balance); }
public void serializer_test() { var events = new List<object>(); for(var i = 1; i< 1000000;i++) { object @event = null; if(i % 1 == 0) { @event = new Deposit {AccountId = "test", Amount = i, At = DateTime.Now}; }else { @event = new WithDraw {AccountId = "test", Amount = i, At = DateTime.Now}; } events.Add(@event); } var msJsonSerializer = new JsonSerializer(); ShowTimeItTakes(events,msJsonSerializer); var protoBufSerializer = new ProtoBufSerializer(); ShowTimeItTakes(events,protoBufSerializer); }