public void Save(IEnumerable <DomainEvent> events, SessionInfo sessionInfo) { foreach (var @event in events) { @event.SessionInfo = sessionInfo; var toSave = new PersistedDomainEvent(@event); var shouldBeNull = _persistanceStore.Get <PersistedDomainEvent>(toSave.Id); if (shouldBeNull != null) { var error = string.Format("Cannot save an event with an existing ID! Id: {0}, type={1}", toSave.Id, @event.GetType()); _logger.Error(error); throw new ArgumentException(error); } _persistanceStore.Save(toSave); } }
public void TestObjectCanBeStored() { var persistedObject = new PersistedString { Content = "content", Id = "Id" }; PersistanceStore.Save(persistedObject); var saved = PersistanceStore.Get <PersistedString>("Id"); Assert.IsNotNull(saved); Assert.AreEqual("Id", saved.Id); Assert.AreEqual("content", saved.Content); }