当前位置: 首页>>代码示例>>C#>>正文


C# EventSubscription.GetExecutionStrategy方法代码示例

本文整理汇总了C#中EventSubscription.GetExecutionStrategy方法的典型用法代码示例。如果您正苦于以下问题:C# EventSubscription.GetExecutionStrategy方法的具体用法?C# EventSubscription.GetExecutionStrategy怎么用?C# EventSubscription.GetExecutionStrategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventSubscription的用法示例。


在下文中一共展示了EventSubscription.GetExecutionStrategy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetExecutionStrategyDoesNotExecuteActionIfFilterReturnsFalse

        public void GetExecutionStrategyDoesNotExecuteActionIfFilterReturnsFalse()
        {
            bool actionExecuted = false;
            var actionDelegate = new Mock<IDelegateReference>();

            actionDelegate.SetupGet(d => d.Target).Returns((Action<int>)delegate { actionExecuted = true; });

            var filterDelegate = new Mock<IDelegateReference>();

            filterDelegate.SetupGet(d => d.Target).Returns((Predicate<int>)delegate { return false; });

            var eventSubscription = new EventSubscription<int>(actionDelegate.Object, filterDelegate.Object);

            var publishAction = eventSubscription.GetExecutionStrategy();

            publishAction.Invoke(new object[] { null });

            Assert.That(actionExecuted, Is.False);
        }
开发者ID:pleb,项目名称:Tank,代码行数:19,代码来源:EventSubscriptionFixture.cs

示例2: GetExecutionStrategyShouldReturnDelegateThatExecutesTheFilterAndThenTheAction

        public void GetExecutionStrategyShouldReturnDelegateThatExecutesTheFilterAndThenTheAction()
        {
            var executedDelegates = new List<string>();

            var actionDelegate = new Mock<IDelegateReference>();

            actionDelegate.SetupGet(d => d.Target).Returns((Action<object>) delegate { executedDelegates.Add("Action"); });

            var filterDelegate = new Mock<IDelegateReference>();

            filterDelegate.SetupGet(d => d.Target).Returns((Predicate<object>) delegate { executedDelegates.Add("Filter"); return true; });

            var eventSubscription = new EventSubscription<object>(actionDelegate.Object, filterDelegate.Object);

            var publishAction = eventSubscription.GetExecutionStrategy();

            Assert.That(publishAction, Is.Not.Null);

            publishAction.Invoke(null);

            Assert.That(executedDelegates.Count, Is.EqualTo(2));
            Assert.That(executedDelegates[0], Is.EqualTo("Filter"));
            Assert.That(executedDelegates[1], Is.EqualTo("Action"));
        }
开发者ID:pleb,项目名称:Tank,代码行数:24,代码来源:EventSubscriptionFixture.cs

示例3: StrategyPassesArgumentToDelegates

        public void StrategyPassesArgumentToDelegates()
        {
            string passedArgumentToAction = null;
            string passedArgumentToFilter = null;

            var actionDelegateReference = new MockDelegateReference((Action<string>)(obj => passedArgumentToAction = obj));
            var filterDelegateReference = new MockDelegateReference((Predicate<string>)(obj =>
                                                                                            {
                                                                                                passedArgumentToFilter = obj;
                                                                                                return true;
                                                                                            }));

            var eventSubscription = new EventSubscription<string>(actionDelegateReference, filterDelegateReference);
            var publishAction = eventSubscription.GetExecutionStrategy();

            publishAction.Invoke(new[] { "TestString" });

            Assert.AreEqual("TestString", passedArgumentToAction);
            Assert.AreEqual("TestString", passedArgumentToFilter);
        }
开发者ID:jeffras,项目名称:Prism-4-with-WinForms,代码行数:20,代码来源:EventSubscriptionFixture.cs

示例4: GetPublishActionDoesNotExecuteActionIfFilterReturnsFalse

        public void GetPublishActionDoesNotExecuteActionIfFilterReturnsFalse()
        {
            bool actionExecuted = false;
            var actionDelegateReference = new MockDelegateReference()
            {
                Target = (Action<int>)delegate { actionExecuted = true; }
            };
            var filterDelegateReference = new MockDelegateReference((Predicate<int>)delegate
                                                                                            {
                                                                                                return false;
                                                                                            });

            var eventSubscription = new EventSubscription<int>(actionDelegateReference, filterDelegateReference);


            var publishAction = eventSubscription.GetExecutionStrategy();

            publishAction.Invoke(new object[] { null });

            Assert.IsFalse(actionExecuted);
        }
开发者ID:jeffras,项目名称:Prism-4-with-WinForms,代码行数:21,代码来源:EventSubscriptionFixture.cs

示例5: GetPublishActionReturnsNullIfFilterIsNull

        public void GetPublishActionReturnsNullIfFilterIsNull()
        {
            var actionDelegateReference = new MockDelegateReference((Action<object>)delegate { });
            var filterDelegateReference = new MockDelegateReference((Predicate<object>)delegate { return true; });

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

            var publishAction = eventSubscription.GetExecutionStrategy();

            Assert.IsNotNull(publishAction);

            filterDelegateReference.Target = null;

            publishAction = eventSubscription.GetExecutionStrategy();

            Assert.IsNull(publishAction);
        }
开发者ID:jeffras,项目名称:Prism-4-with-WinForms,代码行数:17,代码来源:EventSubscriptionFixture.cs

示例6: GetPublishActionReturnsDelegateThatExecutesTheFilterAndThenTheAction

        public void GetPublishActionReturnsDelegateThatExecutesTheFilterAndThenTheAction()
        {
            var executedDelegates = new List<string>();
            var actionDelegateReference =
                new MockDelegateReference((Action<object>)delegate { executedDelegates.Add("Action"); });

            var filterDelegateReference = new MockDelegateReference((Predicate<object>)delegate
                                                {
                                                    executedDelegates.Add(
                                                        "Filter");
                                                    return true;

                                                });

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


            var publishAction = eventSubscription.GetExecutionStrategy();

            Assert.IsNotNull(publishAction);

            publishAction.Invoke(null);

            Assert.AreEqual(2, executedDelegates.Count);
            Assert.AreEqual("Filter", executedDelegates[0]);
            Assert.AreEqual("Action", executedDelegates[1]);
        }
开发者ID:jeffras,项目名称:Prism-4-with-WinForms,代码行数:27,代码来源:EventSubscriptionFixture.cs

示例7: GetPublishActionReturnsNullIfActionIsNull

        public void GetPublishActionReturnsNullIfActionIsNull()
        {
            var actionDelegateReference = new MockDelegateReference((Action<object>)delegate { });
            var filterDelegateReference = new MockDelegateReference((Predicate<object>)delegate { return true; });

            var eventSubscription = new EventSubscription<object>(actionDelegateReference, filterDelegateReference, null, EventCommunicatorsRelationship.All);

            var publishAction = eventSubscription.GetExecutionStrategy();

            Assert.NotNull(publishAction);

            actionDelegateReference.Target = null;

            publishAction = eventSubscription.GetExecutionStrategy();

            Assert.Null(publishAction);
        }
开发者ID:Marfusios,项目名称:MKEventAggregator,代码行数:17,代码来源:EventSubscriptionTests.cs

示例8: GetExecutionStrategyShouldReturnNullIfActionIsNull

        public void GetExecutionStrategyShouldReturnNullIfActionIsNull()
        {
            var actionDelegate = new Mock<IDelegateReference>();

            actionDelegate.SetupGet(d => d.Target).Returns((Action<object>)delegate { });

            var filterDelegate = new Mock<IDelegateReference>();

            filterDelegate.SetupGet(d => d.Target).Returns((Predicate<object>)delegate { return true; });

            var eventSubscription = new EventSubscription<object>(actionDelegate.Object, filterDelegate.Object);

            var publishAction = eventSubscription.GetExecutionStrategy();

            Assert.That(publishAction, Is.Not.Null);

            actionDelegate.SetupGet(d => d.Target).Returns(null);

            publishAction = eventSubscription.GetExecutionStrategy();

            Assert.That(publishAction, Is.Null);
        }
开发者ID:pleb,项目名称:Tank,代码行数:22,代码来源:EventSubscriptionFixture.cs

示例9: StrategyShouldPassArgumentToDelegates

        public void StrategyShouldPassArgumentToDelegates()
        {
            string passedArgumentToAction = null;
            string passedArgumentToFilter = null;

            var actionDelegate = new Mock<IDelegateReference>();

            actionDelegate.SetupGet(d => d.Target).Returns((Action<string>)(obj => passedArgumentToAction = obj));

            var filterDelegate = new Mock<IDelegateReference>();

            filterDelegate.SetupGet(d => d.Target).Returns((Predicate<string>)(obj => { passedArgumentToFilter = obj; return true; }));

            var eventSubscription = new EventSubscription<string>(actionDelegate.Object, filterDelegate.Object);
            var publishAction = eventSubscription.GetExecutionStrategy();

            publishAction.Invoke(new[] { "TestString" });

            Assert.That(passedArgumentToAction, Is.EqualTo("TestString"));
            Assert.That(passedArgumentToFilter, Is.EqualTo("TestString"));
        }
开发者ID:pleb,项目名称:Tank,代码行数:21,代码来源:EventSubscriptionFixture.cs


注:本文中的EventSubscription.GetExecutionStrategy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。