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


C# Command.CanExecute方法代码示例

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


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

示例1: CanExecuteShouldInvokeCallback

        public void CanExecuteShouldInvokeCallback()
        {
            // arrange
            var canExecute = new Mock<Func<object, bool>>();

            canExecute.Setup( f => f( It.IsAny<object>() ) ).Returns( true );

            var command = new Command<object>( DefaultAction.None, canExecute.Object );

            // act
            command.CanExecute();

            // assert
            canExecute.Verify( f => f( null ), Times.Once() );
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:15,代码来源:CommandTTest.cs

示例2: CanExecute_ShouldReturnCorrectValue

		public void CanExecute_ShouldReturnCorrectValue(
			bool canExecute,
			object arg,
			ISchedulers schedulers,
			Mock<ICanExecuteStrategy<object>> canExecuteStrat)
		{
			//arrange
			canExecuteStrat.Setup(c => c.CanExecute(It.IsAny<object>())).Returns(canExecute);
			var sut = new Command<object>(o => { }, schedulers, "name", canExecuteStrat.Object);
			//act
			var actual = sut.CanExecute(arg);

			//assert
			actual.Should().Be(canExecute);
		}
开发者ID:Galad,项目名称:Hanno,代码行数:15,代码来源:CommandTests.cs

示例3: CanExecute_ShouldBeCalledWithArg

		public void CanExecute_ShouldBeCalledWithArg(
		  object arg,
			ISchedulers schedulers,
			Mock<ICanExecuteStrategy<object>> canExecuteStrat)
		{
			//arrange
			object actual = null;
			canExecuteStrat.Setup(c => c.CanExecute(It.IsAny<object>())).Returns(true);
			var sut = new Command<object>(o => { }, schedulers, "name", canExecuteStrat.Object);

			//act
			sut.CanExecute(arg);

			//assert
			canExecuteStrat.Verify(c => c.CanExecute(arg));
		}
开发者ID:Galad,项目名称:Hanno,代码行数:16,代码来源:CommandTests.cs

示例4: RunTest

        internal IEnumerable<SelectedItemCollection> RunTest( IEnumerable<SelectedItemCollection> selections )
        {
            PutInOrgView(false);

            Command = CreateCommand();

            ((ICommand)Command).SetMainWindow(Program.MainWindow.CommandInterface);

            bool noneExecuted = true;

            foreach (SelectedItemCollection selection in selections)
            {
                ((ICommand)Command).SetSelection(selection);

                if (MW<bool>(() => Command.CanExecute()))
                {
                    noneExecuted = false;
                    SelectNodes(selection);

                    yield return selection;
                }
            }

            Assert.IsFalse(noneExecuted, "No tests were executed");
        }
开发者ID:ChrisH4rding,项目名称:xenadmin,代码行数:25,代码来源:CommandTest.cs

示例5: CanExecute

		public void CanExecute ([Values (true, false)] bool expected)
		{
			bool canExecuteRan = false;
			var cmd = new Command (() => { }, () => {
				canExecuteRan = true;
				return expected;
			});

			Assert.AreEqual(expected, cmd.CanExecute (null));
			Assert.True (canExecuteRan);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:11,代码来源:CommandTests.cs

示例6: GenericCanExecute

		public void GenericCanExecute ([Values (true, false)] bool expected)
		{
			string result = null;
			var cmd = new Command<string> (s => { }, s => {
				result = s;
				return expected;
			});

			Assert.AreEqual (expected, cmd.CanExecute ("Foo"));
			Assert.AreEqual ("Foo", result);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:11,代码来源:CommandTests.cs

示例7: Constructor

		public void Constructor ()
		{
			var cmd = new Command (() => { });
			Assert.True (cmd.CanExecute (null));
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:5,代码来源:CommandTests.cs

示例8: TestCanExecIfTrue

 public void TestCanExecIfTrue()
 {
     Command<object> command = new Command<object>(Mock.Of<Action<object>>(), () => true);
     Assert.IsTrue(command.CanExecute(null));
 }
开发者ID:KatrukSergii,项目名称:CallCenter,代码行数:5,代码来源:CommandTests.cs


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