Example #1
0
        public void ShouldPassParametersCorrectly()
        {
            IDelegateReference actionDelegateReference = new MockDelegateReference
            {
                Target =
                    (Action <object>)(arg1 =>
                {
                    return;
                })
            };
            IDelegateReference filterDelegateReference = new MockDelegateReference
            {
                Target = (Predicate <object>)(arg => true)
            };

            var mockSyncContext = new MockSynchronizationContext();

            DispatcherEventSubscription <object> eventSubscription = new DispatcherEventSubscription <object>(actionDelegateReference, filterDelegateReference, mockSyncContext);

            var executionStrategy = eventSubscription.GetExecutionStrategy();

            Assert.IsNotNull(executionStrategy);

            object argument1 = new object();

            executionStrategy.Invoke(new[] { argument1 });

            Assert.AreSame(argument1, mockSyncContext.InvokeArg);
        }
Example #2
0
        public void ShouldCallInvokeOnDispatcher()
        {
            IDelegateReference actionDelegateReference = new MockDelegateReference
            {
                Target = (Action <object>)(arg =>
                {
                    return;
                })
            };

            IDelegateReference filterDelegateReference = new MockDelegateReference
            {
                Target = (Predicate <object>)(arg => true)
            };
            var mockSyncContext = new MockSynchronizationContext();

            var eventSubscription = new DispatcherEventSubscription <object>(
                actionDelegateReference, filterDelegateReference, mockSyncContext);

            eventSubscription.GetExecutionStrategy().Invoke(new object[0]);

            Assert.IsTrue(mockSyncContext.InvokeCalled);
        }