public Builder WithTransport <TTransport>() where TTransport : ITransportConfig { var transport = Activator.CreateInstance <TTransport>(); if (null != transport.SenderFactory) { SenderCache.AddFactory(transport.SenderFactory); } if (null != transport.ReceiverFactory) { ReceiverCache.AddFactory(transport.ReceiverFactory); } if (null != transport.PublisherFactory) { PublisherCache.AddFactory(transport.PublisherFactory); } if (null != transport.SubscriberFactory) { SubscriberCache.AddFactory(transport.SubscriberFactory); } return(this); }
public Builder WithTransport <TTransport>(TTransport transport, Action <ITransportSetup> config) where TTransport : ITransportConfig { if (null != transport.SenderFactory) { SenderCache.AddFactory(transport.SenderFactory); } if (null != transport.ReceiverFactory) { ReceiverCache.AddFactory(transport.ReceiverFactory); } if (null != transport.PublisherFactory) { PublisherCache.AddFactory(transport.PublisherFactory); } if (null != transport.SubscriberFactory) { SubscriberCache.AddFactory(transport.SubscriberFactory); } config(transport.Configurer); return(this); }
public void AddFactory_WithNullFactory_ThrowsArgumentNullException() { // Arrange var cache = new PublisherCache(monitorCache); // Act TestDelegate addFactory = () => cache.AddFactory(null); // Assert Assert.That(addFactory, Throws.ArgumentNullException); }
public void Publish_WithNullMessage_ThrowsArgumentNullException() { // Arrange var cache = new PublisherCache(monitorCache); // Act TestDelegate publish = () => cache.Publish <object>(null); // Assert Assert.That(publish, Throws.ArgumentNullException); }
public void AddPublisher_WithNoFactory_ThrowsMissingFactoryException() { // Arrange var cache = new PublisherCache(monitorCache); // Act TestDelegate addPublisher = () => cache.AddPublisher <IPublisher>(address); // Assert Assert.That(addPublisher, Throws.TypeOf <MissingFactoryException>()); }
public void AddPublisher_WithNullAddress_ThrowsArgumentNullException() { // Arrange var cache = new PublisherCache(monitorCache); // Act TestDelegate addPublisher = () => cache.AddPublisher <IPublisher>(null); // Assert Assert.That(addPublisher, Throws.ArgumentNullException); }
public void AddFactory_WithFactory_AddsMonitorToMonitorCache() { // Arrange var cache = new PublisherCache(monitorCache); // Act cache.AddFactory(factory); // Assert mockMonitorCache.Verify(m => m.AddMonitor(It.IsIn(monitor)), Times.Once); }
public void AddFactory_WithFactory_AddsToFactoryList() { // Arrange var cache = new PublisherCache(monitorCache); // Act cache.AddFactory(factory); // Assert Assert.That(cache.PublisherFactories.Count, Is.EqualTo(1)); }
public void AddPublisher_WithFactory_CallsFactoryCreatePublisher() { // Arrange var cache = new PublisherCache(monitorCache); cache.AddFactory(factory); // Act cache.AddPublisher <IPublisher>(address); // Assert mockFactory.Verify(m => m.CreatePublisher(It.IsIn(address)), Times.Once); }
public void AddFactory_WithExistingFactoryForPublisherType_DoesNothing() { // Arrange var cache = new PublisherCache(monitorCache); cache.AddFactory(factory); // Act cache.AddFactory(factory); // Assert mockMonitorCache.Verify(m => m.AddMonitor(It.IsIn(monitor)), Times.Once); Assert.That(cache.PublisherFactories.Count, Is.EqualTo(1)); }
public void Publish_WithPublisherAdded_CallsPublish() { // Arrange var topicEvent = "something"; var cache = new PublisherCache(monitorCache); cache.AddFactory(factory); cache.AddPublisher <IPublisher>(address); // Act cache.Publish(topicEvent); // Assert mockPublisher.Verify(m => m.Publish(It.IsIn(topicEvent)), Times.Once); }
public void AddPublisher_WithExistingPublisherForAddress_ThrowsInvalidOperationException() { // Arrange var address = TcpAddress.Wildcard(5555); // Doesn't seem to work when using the mockAddress var cache = new PublisherCache(monitorCache); cache.AddFactory(factory); cache.AddPublisher <IPublisher>(address); // Act TestDelegate addPublisher = () => cache.AddPublisher <IPublisher>(address); // Assert Assert.That(addPublisher, Throws.InvalidOperationException); }
public Builder(string name) { this.name = name; TopicRouter = new TopicRouter(); MonitorCache = new MonitorCache(); RequestRouter = new RequestRouter(); PackageFactory = new PackageFactory(); TopicDispatcher = new TopicDispatcher(); RequestDispatcher = new RequestDispatcher(); SubscriptionsCache = new SubscriptionsCache(); SerializerCache = new SerializerCache(); SenderCache = new SenderCache(RequestRouter, MonitorCache); ReceiverCache = new ReceiverCache(MonitorCache); PublisherCache = new PublisherCache(MonitorCache); SubscriberCache = new SubscriberCache(TopicRouter, MonitorCache, SubscriptionsCache); }
public Builder WithPublisher <TPublisher>(IAddress address) where TPublisher : IPublisher { PublisherCache.AddPublisher <TPublisher>(address); return(this); }