public void WhenExecuteExtensionWithNullCommands_ThenThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => CommandRegistryExtensions.Execute( Mock.Of <ICommandRegistry <BaseCommand> >(), default(IEnumerable <BaseCommand>))); }
public void WhenExecuteExtensionOnNullBusWithEmptyCommands_ThenThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => CommandRegistryExtensions.Execute( default(ICommandRegistry <BaseCommand>), Enumerable.Empty <BaseCommand>())); }
public void WhenExecuteExtensionOnNullBus_ThenThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => CommandRegistryExtensions.Execute( default(ICommandRegistry <BaseCommand>), new FooCommand())); }
public void WhenExecuteExtensionWithNullHeadersAndCommands_ThenThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => CommandRegistryExtensions.Execute( Mock.Of <ICommandRegistry <BaseCommand> >(), Enumerable.Empty <BaseCommand>(), default(IDictionary <string, object>))); }
public void WhenExecuteExtensionWithHeadersAndCommands_ThenCopiesDictionary() { var headers = new Dictionary <string, object>(); headers.Add("IP", "localhost"); var bus = new Mock <ICommandRegistry <BaseCommand> >(); CommandRegistryExtensions.Execute( bus.Object, new BaseCommand[] { new FooCommand() }, headers); bus.Verify(x => x.Execute(It.IsAny <BaseCommand>(), It.Is <IDictionary <string, object> >(dict => Object.ReferenceEquals(dict, headers))), Times.Never()); bus.Verify(x => x.Execute(It.IsAny <BaseCommand>(), It.Is <IDictionary <string, object> >(dict => dict.ContainsKey("IP") && ((string)dict["IP"]) == "localhost"))); }
public void WhenExecuteExtensionWithCommands_ThenCreatesNewHeadersForEach() { var headers = new HashSet <IDictionary <string, object> >(); var bus = new Mock <ICommandRegistry <BaseCommand> >(); bus.Setup(x => x.Execute(It.IsAny <BaseCommand>(), It.IsAny <IDictionary <string, object> >())) .Callback((BaseCommand cmd, IDictionary <string, object> h) => headers.Add(h)); CommandRegistryExtensions.Execute( bus.Object, new BaseCommand[] { new FooCommand(), new FooCommand() }); Assert.Equal(2, headers.Count); var dupe = new Dictionary <string, object>(); headers.Add(dupe); headers.Add(dupe); Assert.Equal(3, headers.Count); }