public void EventBusThrowsIfMessageNameIsNotCorrectlyFormatted() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Throws<ArgumentException>(() => eventBus.Notify("StubEventHandlerIncrement", new Dictionary<string, object>())); }
public void EventBusThrowsIfMessageNameIsNotCorrectlyFormatted() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Throws <ArgumentException>(() => eventBus.Notify("StubEventHandlerIncrement", new Dictionary <string, object>())); }
public void EventsAreCorrectlyDispatchedToEventHandlers() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Equal(0, stub1.Count); eventBus.Notify("ITestEventHandler.Increment", new Dictionary <string, object>()); Assert.Equal(1, stub1.Count); }
public void EventHandlerWontBeCalledWhenNoParameterMatchExists2() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Equal(0, stub1.Result); Dictionary<string, object> arguments = new Dictionary<string, object>(); eventBus.Notify("ITestEventHandler.Sum", arguments); Assert.Equal(0, stub1.Result); }
public void EnumerableResultsAreTreatedLikeSelectMany() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); var results = eventBus.Notify("ITestEventHandler.Gather", new Dictionary<string, object> { { "a", 42 }, { "b", "alpha" } }).Cast<string>(); Assert.Equal(3, results.Count()); Assert.Contains("42", results); Assert.Contains("alpha", results); Assert.Contains("[42,alpha]", results); }
public void StringResultsAreTreatedLikeSelect() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); var results = eventBus.Notify("ITestEventHandler.GetString", new Dictionary <string, object>()).Cast <string>(); Assert.Equal(2, results.Count()); Assert.Contains("Foo", results); Assert.Contains("Bar", results); }
public void NonStringNonEnumerableResultsAreTreatedLikeSelect() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); var results = eventBus.Notify("ITestEventHandler.GetInt", new Dictionary <string, object>()).Cast <int>(); Assert.Equal(2, results.Count()); Assert.Contains(1, results); Assert.Contains(2, results); }
public void EventHandlerWontBeCalledWhenNoParameterMatchExists2() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Equal(0, stub1.Result); Dictionary <string, object> arguments = new Dictionary <string, object>(); eventBus.Notify("ITestEventHandler.Sum", arguments); Assert.Equal(0, stub1.Result); }
public void EventParametersAreCorrectlyPassedToExactlyMatchingMethodWhenThereIsOne2() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Equal(0, stub1.Result); Dictionary <string, object> arguments = new Dictionary <string, object>(); arguments["a"] = 1000; eventBus.Notify("ITestEventHandler.Sum", arguments); Assert.Equal(3000, stub1.Result); }
public void EventParametersArePassedInCorrectOrderToEventHandlers() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Equal(0, stub1.Result); Dictionary <string, object> arguments = new Dictionary <string, object>(); arguments["a"] = 2600; arguments["b"] = 5200; eventBus.Notify("ITestEventHandler.Substract", arguments); Assert.Equal(-2600, stub1.Result); }
public void EnumerableResultsAreTreatedLikeSelectMany() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); var results = eventBus.Notify("ITestEventHandler.Gather", new Dictionary <string, object> { { "a", 42 }, { "b", "alpha" } }).Cast <string>(); Assert.Equal(3, results.Count()); Assert.Contains("42", results); Assert.Contains("alpha", results); Assert.Contains("[42,alpha]", results); }
public void EventParametersAreCorrectlyPassedToMatchingMethod() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Null(stub1.Summary); Dictionary <string, object> arguments = new Dictionary <string, object>(); arguments["a"] = "a"; arguments["b"] = "b"; arguments["c"] = "c"; eventBus.Notify("ITestEventHandler.Concat", arguments); Assert.Equal("abc", stub1.Summary); }
public void EventParametersAreCorrectlyPassedToBestMatchingMethodAndExtraParametersAreIgnored() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Equal(0, stub1.Result); Dictionary <string, object> arguments = new Dictionary <string, object>(); arguments["a"] = 1000; arguments["b"] = 100; arguments["c"] = 10; arguments["e"] = 1; eventBus.Notify("ITestEventHandler.Sum", arguments); Assert.Equal(1110, stub1.Result); }
public void EventParametersArePassedInCorrectOrderToEventHandlers() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Equal(0, stub1.Result); Dictionary<string, object> arguments = new Dictionary<string, object>(); arguments["a"] = 2600; arguments["b"] = 5200; eventBus.Notify("ITestEventHandler.Substract", arguments); Assert.Equal(-2600, stub1.Result); }
public void EventParametersAreCorrectlyPassedToExactlyMatchingMethodWhenThereIsOne2() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Equal(0, stub1.Result); Dictionary<string, object> arguments = new Dictionary<string, object>(); arguments["a"] = 1000; eventBus.Notify("ITestEventHandler.Sum", arguments); Assert.Equal(3000, stub1.Result); }
public void EventsAreCorrectlyDispatchedToEventHandlers() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Equal(0, stub1.Count); eventBus.Notify("ITestEventHandler.Increment", new Dictionary<string, object>()); Assert.Equal(1, stub1.Count); }
public void NonStringNonEnumerableResultsAreTreatedLikeSelect() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); var results = eventBus.Notify("ITestEventHandler.GetInt", new Dictionary<string, object>()).Cast<int>(); Assert.Equal(2, results.Count()); Assert.Contains(1, results); Assert.Contains(2, results); }
public void StringResultsAreTreatedLikeSelect() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); var results = eventBus.Notify("ITestEventHandler.GetString", new Dictionary<string, object>()).Cast<string>(); Assert.Equal(2, results.Count()); Assert.Contains("Foo", results); Assert.Contains("Bar", results); }
public void EventParametersAreCorrectlyPassedToBestMatchingMethodAndExtraParametersAreIgnored() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Equal(0, stub1.Result); Dictionary<string, object> arguments = new Dictionary<string, object>(); arguments["a"] = 1000; arguments["b"] = 100; arguments["c"] = 10; arguments["e"] = 1; eventBus.Notify("ITestEventHandler.Sum", arguments); Assert.Equal(1110, stub1.Result); }
public void EventParametersAreCorrectlyPassedToMatchingMethod() { var stub1 = new StubEventHandler(); var stub2 = new StubEventHandler2(); var eventBus = new DefaultOrchardEventBus(new IEventHandler[] { stub1, stub2 }); Assert.Null(stub1.Summary); Dictionary<string, object> arguments = new Dictionary<string, object>(); arguments["a"] = "a"; arguments["b"] = "b"; arguments["c"] = "c"; eventBus.Notify("ITestEventHandler.Concat", arguments); Assert.Equal("abc", stub1.Summary); }