示例#1
0
        public void WireWithFactoryOptionalParameterNullTest()
        {
            var  dispatcher = new CommandDispatcher(_logFactory, "testBC");
            var  handler    = new CommandRepoHandler();
            bool ack        = false;

            dispatcher.Wire(handler, new FactoryParameter <IInt64Repo>(() => null));
            dispatcher.Dispatch((Int64)1, (delay, acknowledge) => { ack = acknowledge; }, new Endpoint(), "route");

            Assert.That(handler.HandledCommands, Is.EquivalentTo(new object[] { (Int64)1 }), "Some commands were not dispatched");
            Assert.True(ack, "Command was not acked");
        }
示例#2
0
        public void WireWithOptionalParameterTest()
        {
            var  dispatcher = new CommandDispatcher(_logFactory, "testBC");
            var  handler    = new CommandRepoHandler();
            var  int64Repo  = new Int64Repo();
            bool ack        = false;

            dispatcher.Wire(handler, new OptionalParameter <IInt64Repo>(int64Repo));
            dispatcher.Dispatch((Int64)1, (delay, acknowledge) => { ack = acknowledge; }, new Endpoint(), "route");

            Assert.That(handler.HandledCommands, Is.EquivalentTo(new object[] { (Int64)1 }), "Some commands were not dispatched");
            Assert.IsFalse(int64Repo.IsDisposed, "Optional parameter should NOT be disposed");
            Assert.True(ack, "Command was not acked");
        }