public void Init() { var connectionString = ConfigurationManager.AppSettings["ServiceBus.ConnectionString"]; var topicPath = ConfigurationManager.AppSettings["TopicName"]; var subscriptionName = "UnitTest"; var topicDescription = new TopicDescription(topicPath) { MaxSizeInMegabytes = 1024, DefaultMessageTimeToLive = new TimeSpan(0, 1, 0) }; var timeProvider = new UtcTimeProvider(); var logger = new Mock <ILogger>(); _evtPublisher = new EventTopicPublisher(connectionString, topicDescription, timeProvider, logger.Object); var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); if (!namespaceManager.SubscriptionExists(topicPath, subscriptionName)) { namespaceManager.CreateSubscription(topicPath, subscriptionName); } _client = SubscriptionClient.CreateFromConnectionString(connectionString, topicPath, subscriptionName); }
internal static IUnityContainer ResolveCommonDependenciesForMainContainer(IUnityContainer container, bool useSignalRLog, bool verbose) { System.Data.Entity.Database.SetInitializer <EventStoreDbContext>(null); System.Data.Entity.Database.SetInitializer <EventQueueDbContext>(null); var log = useSignalRLog ? (ILogger)SignalRLogger.GetResolvedSignalRLogger(verbose) : new ConsoleLogger(verbose); container.RegisterInstance <ILogger>(log); // Only one instance of the event publisher sould be in a node. container.RegisterInstance <IInMemoryEventPublisher>(new InMemoryEventPublisher(log)); var serializer = new JsonTextSerializer(); container.RegisterInstance <ITextSerializer>(serializer); var time = new UtcTimeProvider() as IUtcTimeProvider; container.RegisterInstance <IUtcTimeProvider>(time); container.RegisterInstance <IGuidProvider>(new SequentialGuid()); // Do not share this with child dependencies container.RegisterInstance <IBus>(new Bus()); return(container); }
private static IUnityContainer ResolveCommonDependenciesForMainContainer(bool useSignalRLog, bool verbose) { var mainContainer = new UnityContainer(); var log = useSignalRLog ? (ILogger)SignalRLogger.GetResolvedSignalRLogger(verbose) : new ConsoleLogger(verbose); mainContainer.RegisterInstance <ILogger>(log); mainPublisher = new InMemoryEventPublisher(log); var serializer = new JsonTextSerializer(); mainContainer.RegisterInstance <ITextSerializer>(serializer); var time = new UtcTimeProvider() as IUtcTimeProvider; mainContainer.RegisterInstance <IUtcTimeProvider>(time); mainContainer.RegisterInstance <IGuidProvider>(new SequentialGuid()); // Do not share this with child dependencies mainContainer.RegisterInstance <IBus>(new Bus()); return(mainContainer); }
public void Init() { var connectionString = ConfigurationManager.AppSettings["ServiceBus.ConnectionString"]; var queueName = ConfigurationManager.AppSettings["EventsQueueName"]; var queueDescription = new QueueDescription(queueName) { MaxSizeInMegabytes = 1024, DefaultMessageTimeToLive = new TimeSpan(0, 1, 0) }; var timeProvider = new UtcTimeProvider(); var logger = new Mock <ILogger>(); _evtPublisher = new EventQueuePublisher(connectionString, queueDescription, logger.Object); _client = QueueClient.CreateFromConnectionString(connectionString, queueName); }
public void Init() { var connectionString = ConfigurationManager.AppSettings["ServiceBus.ConnectionString"]; var queueName = ConfigurationManager.AppSettings["EventsQueueName"]; var queueDescription = new QueueDescription(queueName) { MaxSizeInMegabytes = 1024, DefaultMessageTimeToLive = new TimeSpan(0, 1, 0) }; var timeProvider = new UtcTimeProvider(); var logger = new Mock<ILogger>(); _evtPublisher = new EventQueuePublisher(connectionString, queueDescription, logger.Object); _client = QueueClient.CreateFromConnectionString(connectionString, queueName); }
public void SaveAggregate_ToLocalStorage() { var timeProvider = new UtcTimeProvider(); var eventStore = new AzureTableStorageEventStore("UseDevelopmentStorage=true", timeProvider); var id = Guid.NewGuid(); var aggregate = FakeAggregate.Create(id) as FakeAggregate; aggregate.UpdateText("Some message"); var events = eventStore.Save(aggregate); Assert.AreEqual(2, events.Count()); var retrieved = eventStore.GetById <FakeAggregate>(id); Assert.IsNotNull(retrieved); Assert.AreEqual("Some message", retrieved.Text); }
public void SaveAggregate_ToLocalStorage() { var timeProvider = new UtcTimeProvider(); var eventStore = new AzureTableStorageEventStore("UseDevelopmentStorage=true", timeProvider); var id = Guid.NewGuid(); var aggregate = FakeAggregate.Create(id) as FakeAggregate; aggregate.UpdateText("Some message"); var events = eventStore.Save(aggregate); Assert.AreEqual(2, events.Count()); var retrieved = eventStore.GetById<FakeAggregate>(id); Assert.IsNotNull(retrieved); Assert.AreEqual("Some message", retrieved.Text); }
public void Init() { var connectionString = ConfigurationManager.AppSettings["ServiceBus.ConnectionString"]; var topicPath = ConfigurationManager.AppSettings["TopicName"]; var subscriptionName = "UnitTest"; var topicDescription = new TopicDescription(topicPath) { MaxSizeInMegabytes = 1024, DefaultMessageTimeToLive = new TimeSpan(0, 1, 0) }; var timeProvider = new UtcTimeProvider(); var logger = new Mock<ILogger>(); _evtPublisher = new EventTopicPublisher(connectionString, topicDescription, timeProvider, logger.Object); var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); if (!namespaceManager.SubscriptionExists(topicPath, subscriptionName)) namespaceManager.CreateSubscription(topicPath, subscriptionName); _client = SubscriptionClient.CreateFromConnectionString(connectionString, topicPath, subscriptionName); }