public void All_the_events_from_a_new_event_source_should_add_events_to_event_store() { var mock = MockRepository.GenerateMock<IEventSource>(); mock.Stub(m => mock.Id).Return(Guid.NewGuid()).Repeat.Any(); mock.Stub(m => mock.GetUncommittedEvents()).Return(new ISourcedEvent[] { new FooEvent(mock.Id, 1), new BarEvent(mock.Id, 2) }); var theEventStore = new AzureEventStore(); theEventStore.Save(mock); var storedEvents = theEventStore.GetAllEvents(mock.Id); storedEvents.Count().Should().Be(2); }
public void Saving_an_old_event_source_should_throw_exception() { var mock = MockRepository.GenerateStub<IEventSource>(); mock.Stub(m => mock.Id).Return(Guid.NewGuid()).Repeat.Any(); mock.Stub(m => mock.GetUncommittedEvents()).Return(new ISourcedEvent[] { new FooEvent(mock.Id, 1), new BarEvent(mock.Id, 2) }).Repeat.Once(); var theEventStore = new AzureEventStore(); theEventStore.Save(mock); mock.Stub(m => mock.Version).Return(1); mock.Stub(m => mock.GetUncommittedEvents()).Return(new ISourcedEvent[] { new FooEvent(mock.Id, 3), new BarEvent(mock.Id, 4) }); Action act = () => theEventStore.Save(mock); act.ShouldThrow<ConcurrencyException>(); }
public IEnumerable <RetrievedEventsWithMetaData> ReadAllEvents(EventStoreOffset startOffset, int maxRecordCount) { if (maxRecordCount < 0) { throw new ArgumentOutOfRangeException("maxRecordCount"); } if (!AzureEventStore.IsValid(Config, StoreId)) { yield break; } // CHECK existence using (var cont = AzureEventStore.OpenExistingForReading(Config, StoreId)) { foreach (var record in cont.ReadAll(startOffset, maxRecordCount)) { yield return(record); } } }
public void TearDown() { var theEventStore = new AzureEventStore(); theEventStore.ClearStore(); }