public void ReadMultipleEvents() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = new DataContractContentSerializer( new TypeResolutionTable( new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "user-created", typeof(UserCreated)), new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "email-verified", typeof(EmailVerified)), new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "email-changed", typeof(EmailChanged)))); var obs = new AtomEventObserver <IUserEvent>( eventStreamId, pageSize, storage, serializer); obs.OnNext(new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }); obs.OnNext(new EmailVerified { UserId = eventStreamId, Email = "*****@*****.**" }); obs.OnNext(new EmailChanged { UserId = eventStreamId, NewEmail = "*****@*****.**" }); var events = new FifoEvents <IUserEvent>( eventStreamId, // a Guid storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var user = User.Fold(events); Assert.Equal(eventStreamId, user.Id); Assert.Equal("ploeh", user.Name); Assert.Equal("12345", user.Password); Assert.Equal("*****@*****.**", user.Email); Assert.False(user.EmailVerified); } }
public void WriteASingleEventSynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = DataContractContentSerializer.Scan( typeof(UserCreated).Assembly); IObserver<object> obs = new AtomEventObserver<object>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); Assert.NotEmpty(storage); } }
public void ReadASingleEvent() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = DataContractContentSerializer.Scan( typeof(UserCreated).Assembly); var obs = new AtomEventObserver <object>( eventStreamId, pageSize, storage, serializer); var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); IEnumerable <object> events = new FifoEvents <object>( eventStreamId, // a Guid storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var firstEvent = events.First(); var uc = Assert.IsAssignableFrom <UserCreated>(firstEvent); Assert.Equal(userCreated, uc, new SemanticComparer <UserCreated>()); } }
public void WriteASingleEventSynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = DataContractContentSerializer.Scan( typeof(UserCreated).Assembly); IObserver <object> obs = new AtomEventObserver <object>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); Assert.NotEmpty(storage); } }
public void ReadMultipleEvents() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = DataContractContentSerializer.Scan( typeof(UserCreated).Assembly); var obs = new AtomEventObserver <IUserEvent>( eventStreamId, pageSize, storage, serializer); obs.OnNext(new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }); obs.OnNext(new EmailVerified { UserId = eventStreamId, Email = "*****@*****.**" }); obs.OnNext(new EmailChanged { UserId = eventStreamId, NewEmail = "*****@*****.**" }); var events = new FifoEvents <IUserEvent>( eventStreamId, // a Guid storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var user = User.Fold(events); Assert.Equal(eventStreamId, user.Id); Assert.Equal("ploeh", user.Name); Assert.Equal("12345", user.Password); Assert.Equal("*****@*****.**", user.Email); Assert.False(user.EmailVerified); } }
public void WriteASingleEventSynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); /* Uses file storage to provide a documentation example of how to * do that. */ var directory = new DirectoryInfo( Path.Combine( Environment.CurrentDirectory, Guid.NewGuid().ToString("N"))); try { var storage = new AtomEventsInFiles(directory); var pageSize = 25; var serializer = new DataContractContentSerializer( new TypeResolutionTable( new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "user-created", typeof(UserCreated)), new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "email-verified", typeof(EmailVerified)), new TypeResolutionEntry( "urn:grean:samples:user-sign-up", "email-changed", typeof(EmailChanged)))); IObserver <IUserEvent> obs = new AtomEventObserver <IUserEvent>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); Assert.NotEmpty(storage); } finally { directory.Delete(recursive: true); } }
public void WriteASingleEventSynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); /* Uses file storage to provide a documentation example of how to * do that. */ var directory = new DirectoryInfo( Path.Combine( Environment.CurrentDirectory, Guid.NewGuid().ToString("N"))); try { var storage = new AtomEventsInFiles(directory); var pageSize = 25; /* This is an example of using * DataContractContentSerializer.CreateTypeResolver, so it * should not be refactored to one of the terser * alternatives. */ var resolver = DataContractContentSerializer.CreateTypeResolver( typeof(UserCreated).Assembly); var serializer = new DataContractContentSerializer(resolver); IObserver <IUserEvent> obs = new AtomEventObserver <IUserEvent>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); Assert.NotEmpty(storage); } finally { directory.Delete(recursive: true); } }
public void ReadASingleEvent() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = new DataContractContentSerializer( new TypeResolutionTable( new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "user-created", typeof(UserCreated)), new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "email-verified", typeof(EmailVerified)), new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "email-changed", typeof(EmailChanged)))); var obs = new AtomEventObserver <object>( eventStreamId, pageSize, storage, serializer); var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); IEnumerable <object> events = new FifoEvents <object>( eventStreamId, // a Guid storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var firstEvent = events.First(); var uc = Assert.IsAssignableFrom <UserCreated>(firstEvent); Assert.Equal(userCreated, uc, new SemanticComparer <UserCreated>()); } }
public void WriteASingleEventSynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); /* Uses file storage to provide a documentation example of how to * do that. */ var directory = new DirectoryInfo( Path.Combine( Environment.CurrentDirectory, Guid.NewGuid().ToString("N"))); try { var storage = new AtomEventsInFiles(directory); var pageSize = 25; /* This is an example of using * DataContractContentSerializer.CreateTypeResolver, so it * should not be refactored to one of the terser * alternatives. */ var resolver = DataContractContentSerializer.CreateTypeResolver( typeof(UserCreated).Assembly); var serializer = new DataContractContentSerializer(resolver); IObserver<IUserEvent> obs = new AtomEventObserver<IUserEvent>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); Assert.NotEmpty(storage); } finally { directory.Delete(recursive: true); } }
public void WriteASingleEventSynchronously() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = new DataContractContentSerializer( new TypeResolutionTable( new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "user-created", typeof(UserCreated)), new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "email-verified", typeof(EmailVerified)), new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "email-changed", typeof(EmailChanged)))); IObserver <object> obs = new AtomEventObserver <object>( eventStreamId, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); Assert.NotEmpty(storage); } }
public void ReadASingleEvent() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = DataContractContentSerializer.Scan( typeof(UserCreated).Assembly); var obs = new AtomEventObserver<object>( eventStreamId, pageSize, storage, serializer); var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; obs.OnNext(userCreated); IEnumerable<object> events = new FifoEvents<object>( eventStreamId, // a Guid storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var firstEvent = events.First(); var uc = Assert.IsAssignableFrom<UserCreated>(firstEvent); Assert.Equal(userCreated, uc, new SemanticComparer<UserCreated>()); } }
public void ReadMultipleEvents() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; /* This is an example of how to use the TypeResolutionEntry * class, so it should not be refactored to one of the terser * alternatives. */ var resolver = new TypeResolutionTable( new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "user-created", typeof(UserCreated)), new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "email-verified", typeof(EmailVerified)), new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "email-changed", typeof(EmailChanged))); var serializer = new DataContractContentSerializer(resolver); var obs = new AtomEventObserver<object>( eventStreamId, pageSize, storage, serializer); obs.OnNext(new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }); obs.OnNext(new EmailVerified { UserId = eventStreamId, Email = "*****@*****.**" }); obs.OnNext(new EmailChanged { UserId = eventStreamId, NewEmail = "*****@*****.**" }); var events = new FifoEvents<object>( eventStreamId, // a Guid storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var user = User.Fold(events); Assert.Equal(eventStreamId, user.Id); Assert.Equal("ploeh", user.Name); Assert.Equal("12345", user.Password); Assert.Equal("*****@*****.**", user.Email); Assert.False(user.EmailVerified); } }
public void ReadMultipleEvents() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; var serializer = DataContractContentSerializer.Scan( typeof(UserCreated).Assembly); var obs = new AtomEventObserver<IUserEvent>( eventStreamId, pageSize, storage, serializer); obs.OnNext(new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }); obs.OnNext(new EmailVerified { UserId = eventStreamId, Email = "*****@*****.**" }); obs.OnNext(new EmailChanged { UserId = eventStreamId, NewEmail = "*****@*****.**" }); var events = new FifoEvents<IUserEvent>( eventStreamId, // a Guid storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var user = User.Fold(events); Assert.Equal(eventStreamId, user.Id); Assert.Equal("ploeh", user.Name); Assert.Equal("12345", user.Password); Assert.Equal("*****@*****.**", user.Email); Assert.False(user.EmailVerified); } }
public void ReadMultipleEvents() { var eventStreamId = new Guid("A0E50259-7345-48F9-84B4-BEEB5CEC662C"); using (var storage = new AtomEventsInMemory()) { var pageSize = 25; /* This is an example of how to use the TypeResolutionEntry * class, so it should not be refactored to one of the terser * alternatives. */ var resolver = new TypeResolutionTable( new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "user-created", typeof(UserCreated)), new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "email-verified", typeof(EmailVerified)), new TypeResolutionEntry( "urn:grean:samples:user-on-boarding", "email-changed", typeof(EmailChanged))); var serializer = new DataContractContentSerializer(resolver); var obs = new AtomEventObserver <object>( eventStreamId, pageSize, storage, serializer); obs.OnNext(new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }); obs.OnNext(new EmailVerified { UserId = eventStreamId, Email = "*****@*****.**" }); obs.OnNext(new EmailChanged { UserId = eventStreamId, NewEmail = "*****@*****.**" }); var events = new FifoEvents <object>( eventStreamId, // a Guid storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var user = User.Fold(events); Assert.Equal(eventStreamId, user.Id); Assert.Equal("ploeh", user.Name); Assert.Equal("12345", user.Password); Assert.Equal("*****@*****.**", user.Email); Assert.False(user.EmailVerified); } }
public void WriteTo(AtomEventObserver <T> observer, T @event) { observer.OnNext(@event); }