public void CONVERT_FILTER_SHOULD_USE_TO_STRING_ON_CORRECT_KEY() { //Arrange var filter = new ConvertFilter(); const string key = "key"; const string stringValue = "hello"; filter.AddToString(key); var obj = new MockEventObject(stringValue); var eventProperties = new Dictionary <string, object> { { key, obj } }; //Act filter.PrepareEvent(eventProperties); //Assert eventProperties[key].Should().Be(stringValue); }
public void RemovingItemRemovesSubscribersAndPublishers() { WorkItem workItem = new TestableRootWorkItem(); EventBrokerStrategy strat = new EventBrokerStrategy(); MockBuilderContext context = new MockBuilderContext(strat); MockEventObject thing = new MockEventObject(); MockEventSubscriber sub = new MockEventSubscriber(); context.Locator.Add(new DependencyResolutionLocatorKey(typeof(WorkItem), null), workItem); strat.BuildUp(context, typeof(MockEventObject), thing, null); strat.BuildUp(context, typeof(MockEventSubscriber), sub, null); Assert.IsFalse(thing.SomeEventIsNull()); Assert.IsFalse(thing.SomeEvent2IsNull()); strat.TearDown(context, thing); Assert.IsTrue(thing.SomeEventIsNull()); Assert.IsTrue(thing.SomeEvent2IsNull()); }
public void EventStrategyAcceptsEventBrokerServices() { WorkItem workItem = new TestableRootWorkItem(); EventBrokerStrategy strat = new EventBrokerStrategy(); MockBuilderContext context = new MockBuilderContext(strat); MockEventObject thing = new MockEventObject(); context.Locator.Add(new DependencyResolutionLocatorKey(typeof(WorkItem), null), workItem); strat.BuildUp(context, typeof(MockEventObject), thing, null); Assert.IsTrue(workItem.EventTopics.Contains("topic1")); Assert.IsTrue(workItem.EventTopics.Get("topic1").ContainsPublication(thing, "SomeEvent")); Assert.IsTrue(workItem.EventTopics.Contains("globalTopic")); Assert.IsTrue(workItem.EventTopics.Get("globalTopic").ContainsPublication(thing, "SomeEvent2")); Assert.IsTrue(workItem.EventTopics.Contains("localSubscriptionTopic")); Assert.IsTrue(workItem.EventTopics.Get("localSubscriptionTopic").ContainsSubscription(thing, "SomeHandler")); Assert.IsTrue(workItem.EventTopics.Contains("globalSubscriptionTopic")); Assert.IsTrue(workItem.EventTopics.Get("globalSubscriptionTopic").ContainsSubscription(thing, "SomeHandle2")); }