Esempio n. 1
0
            public void UnsupportedCallbackTypeThrows()
            {
                ExecutorCallback wrapper = ExecutorCallback.Wrap(42);

                var ex = Record.Exception(() => wrapper.Notify("Notification"));

                Assert.IsType <TargetException>(ex);
            }
Esempio n. 2
0
            public void NullCallbackAlwaysReturnsTrue()
            {
                var callback = ExecutorCallback.Wrap(null);

                var result = callback.ShouldContinue();

                Assert.True(result);
            }
Esempio n. 3
0
            public void ICallbackEventHandler()
            {
                var handler  = new Mock <ICallbackEventHandler>();
                var callback = ExecutorCallback.Wrap(handler.Object);

                callback.Notify("This is the callback value");

                handler.Verify(h => h.RaiseCallbackEvent("This is the callback value"), Times.Once());
            }
Esempio n. 4
0
            public void ICallbackEventHandlerReturningNull()
            {
                var handler  = new Mock <ICallbackEventHandler>();
                var callback = ExecutorCallback.Wrap(handler.Object);

                var result = callback.ShouldContinue();

                Assert.True(result);
            }
Esempio n. 5
0
            public void IMessageSinkReturnsTrueByDefault()
            {
                var handler  = new Mock <IMessageSink>();
                var callback = ExecutorCallback.Wrap(handler.Object);
                // Don't call Notify here

                var result = callback.ShouldContinue();

                Assert.True(result);
            }
Esempio n. 6
0
            public void ICallbackEventHandlerReturningFalse()
            {
                var handler = new Mock <ICallbackEventHandler>();

                handler.Setup(h => h.GetCallbackResult()).Returns("false");
                var callback = ExecutorCallback.Wrap(handler.Object);

                var result = callback.ShouldContinue();

                Assert.False(result);
            }
Esempio n. 7
0
            public void IMessageSink()
            {
                IMessage msg     = null;
                var      handler = new Mock <IMessageSink>();

                handler.Setup(h => h.SyncProcessMessage(It.IsAny <IMessage>()))
                .Callback <IMessage>(_msg => msg = _msg)
                .Returns((IMessage)null);
                var callback = ExecutorCallback.Wrap(handler.Object);

                callback.Notify("This is the callback value");

                Assert.Equal("This is the callback value", msg.Properties["data"]);
            }
Esempio n. 8
0
            public void IMessageSinkReturningFalse()
            {
                var values = new Hashtable {
                    { "data", "false" }
                };
                var message = new Mock <IMessage>();

                message.Setup(m => m.Properties).Returns(values);
                var handler = new Mock <IMessageSink>();

                handler.Setup(h => h.SyncProcessMessage(It.IsAny <IMessage>()))
                .Returns(message.Object);
                var callback = ExecutorCallback.Wrap(handler.Object);

                // Have to call Notify() because that's how we discover the intended ShouldContinue value
                callback.Notify(null);

                var result = callback.ShouldContinue();

                Assert.False(result);
            }
Esempio n. 9
0
            public void NullCallbackDoesNotThrow()
            {
                var callback = ExecutorCallback.Wrap(null);

                Assert.DoesNotThrow(() => callback.Notify("This is the callback value"));
            }