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 CreateTypeResolverReturnsCorrectResult() { var assemblyToScanForEvents = typeof(DataContractContentSerializerTests).Assembly; var mappings = (from t in assemblyToScanForEvents.GetExportedTypes() from a in t.GetCustomAttributes( typeof(DataContractAttribute), inherit: false) .Cast <DataContractAttribute>() where t.IsDefined(a.GetType(), inherit: false) select new TypeResolutionEntry(a.Namespace, a.Name, t)) .ToArray(); Assert.NotEmpty(mappings); var sut = DataContractContentSerializer.CreateTypeResolver( assemblyToScanForEvents); Array.ForEach(mappings, entry => { var expected = entry.ResolvedType; var actual = sut.Resolve(entry.LocalName, entry.XmlNamespace); Assert.Equal(expected, actual); }); }
public async Task WriteASingleEventAsynchronously() { 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, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; await obs.AppendAsync(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 = 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); } }
static FeedController() { s_storage = new AtomEventsInFiles(new DirectoryInfo(Globals.StoragePath)); s_serializer = new DataContractContentSerializer( DataContractContentSerializer .CreateTypeResolver(typeof(ProductEntry).Assembly) ); }
static FeedController() { s_storage = new AtomEventsInFiles(new DirectoryInfo(Globals.StoragePath)); s_serializer = new DataContractContentSerializer( DataContractContentSerializer .CreateTypeResolver(typeof (ProductEntry).Assembly) ); }
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 ScanCanRoundTripAttributedClassInstance( DataContractTestEventX @event) { var actual = DataContractContentSerializer.Scan(@event.GetType().Assembly); var expected = Assert.IsAssignableFrom <DataContractTestEventX>( @event.RoundTrip(actual)); Assert.Equal(expected.Number, @event.Number); Assert.Equal(expected.Text, @event.Text); }
public ProductAddedEventHandler(ILog logger) : base(logger) { var storage = new AtomEventsInFiles(new DirectoryInfo(Globals.StoragePath)); var serializer = new DataContractContentSerializer( DataContractContentSerializer .CreateTypeResolver(typeof(ProductEntry).Assembly) ); _observer = new AtomEventObserver <ProductEntry>( Globals.EventStreamId, 25, storage, serializer ); }
public void CreateTypeResolverWithAssemblyWithoutAnnotatedTypesThrows() { var assembly = typeof(Version).Assembly; Assert.Empty( from t in assembly.GetExportedTypes() from a in t.GetCustomAttributes( typeof(DataContractAttribute), inherit: false) .Cast <DataContractAttribute>() where t.IsDefined(a.GetType(), inherit: false) select t); Assert.Throws <ArgumentException>(() => DataContractContentSerializer.CreateTypeResolver(assembly)); }
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 WriteToXmlWriterWritesCorrectXml( AtomEntry entry, Generator <AtomLink> linkGenerator, DataContractTestEventX tex, DataContractContentSerializer serializer) { // Fixture setup var sb = new StringBuilder(); using (var w = XmlWriter.Create(sb)) { var links = linkGenerator.Take(2).ToList(); var sut = entry .WithContent(new XmlAtomContent(tex)) .WithLinks(links); // Exercise system sut.WriteTo(w, serializer); // Verify outcome w.Flush(); var expected = XDocument.Parse( "<entry xmlns=\"http://www.w3.org/2005/Atom\">" + " <id>" + sut.Id.ToString() + "</id>" + " <title type=\"text\">" + sut.Title + "</title>" + " <published>" + sut.Published.ToString("o") + "</published>" + " <updated>" + sut.Updated.ToString("o") + "</updated>" + " <author>" + " <name>" + sut.Author.Name + "</name>" + " </author>" + " <link href=\"" + links[0].Href.ToString() + "\" rel=\"" + links[0].Rel + "\" />" + " <link href=\"" + links[1].Href.ToString() + "\" rel=\"" + links[1].Rel + "\" />" + " <content type=\"application/xml\">" + " <test-event-x xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://grean.rocks/dc\">" + " <number>" + tex.Number + "</number>" + " <text>" + tex.Text + "</text>" + " </test-event-x>" + " </content>" + "</entry>"); var actual = XDocument.Parse(sb.ToString()); Assert.Equal(expected, actual, new XNodeEqualityComparer()); // Teardown } }
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 ScanCorrectlySerializesAttributedClassInstance( DataContractTestEventX @event) { var actual = DataContractContentSerializer.Scan(@event.GetType().Assembly); var expected = XDocument.Parse( "<test-event-x xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://grean.rocks/dc\">" + " <number>" + @event.Number + "</number>" + " <text>" + @event.Text + "</text>" + "</test-event-x>"); Assert.Equal( expected, XDocument.Parse(@event.AsSerializedString(actual)), new XNodeEqualityComparer()); }
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 SerializeCorrectlySerializesAttributedClassInstance( DataContractContentSerializer sut, DataContractTestEventX dctex) { var sb = new StringBuilder(); using (var w = XmlWriter.Create(sb)) { sut.Serialize(w, dctex); w.Flush(); var actual = sb.ToString(); var expected = XDocument.Parse( "<test-event-x xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://grean.rocks/dc\">" + " <number>" + dctex.Number + "</number>" + " <text>" + dctex.Text + "</text>" + "</test-event-x>"); Assert.Equal(expected, XDocument.Parse(actual), new XNodeEqualityComparer()); } }
public void SutCanRoundTripAttributedClassInstance( DataContractContentSerializer sut, DataContractTestEventX dctex) { using (var ms = new MemoryStream()) using (var w = XmlWriter.Create(ms)) { sut.Serialize(w, dctex); w.Flush(); ms.Position = 0; using (var r = XmlReader.Create(ms)) { var content = sut.Deserialize(r); var actual = Assert.IsAssignableFrom <DataContractTestEventX>(content.Item); Assert.Equal(dctex.Number, actual.Number); Assert.Equal(dctex.Text, actual.Text); } } }
public async Task WriteASingleEventAsynchronously() { 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, // a Guid pageSize, // an Int32 storage, // an IAtomEventStorage object serializer); // an IContentSerializer object var userCreated = new UserCreated { UserId = eventStreamId, UserName = "******", Password = "******", Email = "*****@*****.**" }; await obs.AppendAsync(userCreated); Assert.NotEmpty(storage); } }
public HttpResponseMessage Recent() { var feed = _events.ReadFirst(); if (feed != null) { var sb = new StringBuilder(); using (var xmlWriter = XmlWriter.Create(sb)) { feed.WriteTo(xmlWriter, new DataContractContentSerializer( DataContractContentSerializer.CreateTypeResolver(typeof(ProductEntry).Assembly))); return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(sb.ToString()) }); } } return(new HttpResponseMessage(HttpStatusCode.NoContent)); }
public IEnumerable <ProductEntry> GetFeedEntries(Uri uri) { try { _logger.DebugFormat("Reading reference data from {0}", uri); var response = Client().GetAsync(uri).Result; response.EnsureSuccessStatusCode(); var serializer = new DataContractContentSerializer(DataContractContentSerializer.CreateTypeResolver(typeof(ProductEntry).Assembly)); var feed = AtomFeed.Parse(response.Content.ReadAsStringAsync().Result, serializer); var reader = new ReferenceDataFeedReader <ProductEntry>(_lastReadFeedItemDao, feed); return(reader); } catch (AggregateException ae) { foreach (var exception in ae.Flatten().InnerExceptions) { _logger.InfoFormat("Threw exception getting feed from the Server {0}", uri, exception.Message); } throw new ApplicationException(string.Format("Error retrieving the feed from the server, see log for details")); } }
public IEnumerable<ProductEntry> GetFeedEntries(Uri uri) { try { _logger.DebugFormat("Reading reference data from {0}", uri); var response = Client().GetAsync(uri).Result; response.EnsureSuccessStatusCode(); var serializer = new DataContractContentSerializer(DataContractContentSerializer.CreateTypeResolver(typeof(ProductEntry).Assembly)); var feed = AtomFeed.Parse(response.Content.ReadAsStringAsync().Result, serializer); var reader = new ReferenceDataFeedReader<ProductEntry>(_lastReadFeedItemDao, feed); return reader; } catch (AggregateException ae) { foreach (var exception in ae.Flatten().InnerExceptions) { _logger.InfoFormat("Threw exception getting feed from the Server {0}", uri, exception.Message); } throw new ApplicationException(string.Format("Error retrieving the feed from the server, see log for details")); } }
public void SerializeCorrectlySerializesAttributedClassInstance( DataContractContentSerializer sut, DataContractTestEventX dctex) { var sb = new StringBuilder(); using (var w = XmlWriter.Create(sb)) { sut.Serialize(w, dctex); w.Flush(); var actual = sb.ToString(); var expected = XDocument.Parse( "<test-event-x xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://grean.rocks/dc\">" + " <number>" + dctex.Number + "</number>" + " <text>" + dctex.Text + "</text>" + "</test-event-x>"); Assert.Equal(expected, XDocument.Parse(actual), new XNodeEqualityComparer()); } }
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 ScanWithNullAssemblyThrows() { Assert.Throws <ArgumentNullException>(() => DataContractContentSerializer.Scan(null)); }
public void SutIsContentSerializer(DataContractContentSerializer sut) { Assert.IsAssignableFrom <IContentSerializer>(sut); }
public void CreateTypeResolverWithNullAssemblyThrows() { Assert.Throws <ArgumentNullException>(() => DataContractContentSerializer.CreateTypeResolver(null)); }
public void SutCanRoundTripAttributedClassInstance( DataContractContentSerializer sut, DataContractTestEventX dctex) { using (var ms = new MemoryStream()) using (var w = XmlWriter.Create(ms)) { sut.Serialize(w, dctex); w.Flush(); ms.Position = 0; using (var r = XmlReader.Create(ms)) { var content = sut.Deserialize(r); var actual = Assert.IsAssignableFrom<DataContractTestEventX>(content.Item); Assert.Equal(dctex.Number, actual.Number); Assert.Equal(dctex.Text, actual.Text); } } }
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 SutIsContentSerializer(DataContractContentSerializer sut) { Assert.IsAssignableFrom<IContentSerializer>(sut); }
public static void Run(UnityContainer container) { container.RegisterType <FeedController>(); container.RegisterType <ProductsController>(); container.RegisterInstance(typeof(ILog), LogProvider.For <ProductService>(), new ContainerControlledLifetimeManager()); container.RegisterType <IProductsDAO, ProductsDAO>(); container.RegisterType <AddProductCommandHandler>(); container.RegisterType <ChangeProductCommandHandler>(); container.RegisterType <ProductAddedEventHandler>(); container.RegisterType <ProductChangedEventHandler>(); container.RegisterType <ProductRemovedEventHandler>(); container.RegisterType <RemoveProductCommandHandler>(); var storage = new AtomEventsInFiles(new DirectoryInfo(Globals.StoragePath)); var serializer = new DataContractContentSerializer( DataContractContentSerializer .CreateTypeResolver(typeof(ProductEntry).Assembly) ); var events = new FifoEvents <ProductEntry>( Globals.EventStreamId, storage, serializer); container.RegisterInstance(typeof(IObserver <ProductEntry>), events, new TransientLifetimeManager()); var handlerFactory = new UnityHandlerFactory(container); var subscriberRegistry = new SubscriberRegistry { { typeof(AddProductCommand), typeof(AddProductCommandHandler) }, { typeof(ChangeProductCommand), typeof(ChangeProductCommandHandler) }, { typeof(RemoveProductCommand), typeof(RemoveProductCommandHandler) }, { typeof(ProductAddedEvent), typeof(ProductAddedEventHandler) }, { typeof(ProductRemovedEvent), typeof(ProductRemovedEventHandler) }, }; //create policies var retryPolicy = Policy .Handle <Exception>() .WaitAndRetry(new[] { TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(150) }); var circuitBreakerPolicy = Policy .Handle <Exception>() .CircuitBreaker(1, TimeSpan.FromMilliseconds(500)); var policyRegistry = new PolicyRegistry() { { CommandProcessor.RETRYPOLICY, retryPolicy }, { CommandProcessor.CIRCUITBREAKER, circuitBreakerPolicy } }; var commandProcessor = CommandProcessorBuilder.With() .Handlers(new HandlerConfiguration(subscriberRegistry, handlerFactory)) .Policies(policyRegistry) .Logger(container.Resolve <ILog>()) .NoTaskQueues() .RequestContextFactory(new InMemoryRequestContextFactory()) .Build(); container.RegisterInstance(typeof(IAmACommandProcessor), commandProcessor); }
public void WriteToXmlWriterWritesCorrectXml( AtomEntry entry, Generator<AtomLink> linkGenerator, DataContractTestEventX tex, DataContractContentSerializer serializer) { // Fixture setup var sb = new StringBuilder(); using (var w = XmlWriter.Create(sb)) { var links = linkGenerator.Take(2).ToList(); var sut = entry .WithContent(new XmlAtomContent(tex)) .WithLinks(links); // Exercise system sut.WriteTo(w, serializer); // Verify outcome w.Flush(); var expected = XDocument.Parse( "<entry xmlns=\"http://www.w3.org/2005/Atom\">" + " <id>" + sut.Id.ToString() + "</id>" + " <title type=\"text\">" + sut.Title + "</title>" + " <published>" + sut.Published.ToString("o") + "</published>" + " <updated>" + sut.Updated.ToString("o") + "</updated>" + " <author>" + " <name>" + sut.Author.Name + "</name>" + " </author>" + " <link href=\"" + links[0].Href.ToString() + "\" rel=\"" + links[0].Rel + "\" />" + " <link href=\"" + links[1].Href.ToString() + "\" rel=\"" + links[1].Rel + "\" />" + " <content type=\"application/xml\">" + " <test-event-x xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://grean.rocks/dc\">" + " <number>" + tex.Number + "</number>" + " <text>" + tex.Text + "</text>" + " </test-event-x>" + " </content>" + "</entry>"); var actual = XDocument.Parse(sb.ToString()); Assert.Equal(expected, actual, new XNodeEqualityComparer()); // Teardown } }