public StandaloneTest() { var loggerFactory = new LoggerFactory(); loggerFactory.AddConsole(); var services = new ServiceCollection(); var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appSettings.json").Build(); var settings = new NotificationServiceSettings(); config.GetSection("Notification").Bind(settings); _channelName = $"{settings.ApplicationName}.{settings.ServiceName}"; var options = Options.Create(settings); var diagnostic = new MyDiagnosticSource(); var remoteSettings = new RemoteServiceSettings { IsLocal = true }; services.AddPublisher(remoteSettings, options, loggerFactory, diagnostic); services.AddSubscriber(remoteSettings, options, loggerFactory, diagnostic); _serviceProvider = services.BuildServiceProvider(); _publisher = _serviceProvider.GetService <IPublisherClientService>(); _subscriber = _serviceProvider.GetService <SubscriberClientService>(); }
public RemotePublisherTest() { var loggerFactory = new LoggerFactory(); loggerFactory.AddConsole(); var services = new ServiceCollection(); var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appSettings-RemotePublisher.json").Build(); var settings = new NotificationServiceSettings(); config.GetSection("Notification").Bind(settings); _channelName = $"{settings.ApplicationName}.{settings.ServiceName}"; var options = Options.Create(settings); var diagnostic = new MyDiagnosticSource(); // Arrange a local subscriber var subscriberSettings = new RemoteServiceSettings { IsLocal = true, Uri = "" }; services.AddSubscriber(subscriberSettings, options, loggerFactory, diagnostic); // Arrange a remote publisher //start a publisher web site var testHost = new TestPublisherHost(); services.AddPublisher(new RemoteServiceSettings { IsLocal = false, Uri = testHost.Server.BaseAddress.ToString() }, options, loggerFactory, diagnostic, testHost.Server.CreateClient()); _serviceProvider = services.BuildServiceProvider(); _subscriber = _serviceProvider.GetService <SubscriberClientService>(); _publisher = _serviceProvider.GetService <IPublisherClientService>(); }