コード例 #1
0
ファイル: RelayCommandTest.cs プロジェクト: jprofi/MSProjects
        public void TestRelayCommandWithNullValueTypeParam()
        {
            RelayCommand<int> command = new RelayCommand<int>(
                e => Assert.That(e, Is.EqualTo(0)),
                i =>
                    {
                        Assert.That(i, Is.EqualTo(0));
                        return true;
                    });

            Assert.That(command.HasCanExecuteFunction, Is.True);
            Assert.That(command.CanExecute(null), Is.True);
            command.Execute(null);
            Assert.That(command.CanExecute(null), Is.True);
        }
コード例 #2
0
ファイル: RelayCommandTest.cs プロジェクト: jprofi/MSProjects
        public void TestRelayCommandWithParamNoCanExecute()
        {
            const string parameterString = "567";
            int parameterAsInt = int.Parse(parameterString);

            bool actionPerformed = false;

            string executeActionParam = string.Empty;

            RelayCommand<string> command = new RelayCommand<string>(
                e =>
                    {
                        executeActionParam = e;
                        actionPerformed = true;
                    });

            Assert.That(command.HasCanExecuteFunction, Is.False);
            Assert.That(command.CanExecute(parameterString), Is.True);
            command.Execute(parameterAsInt);
            Assert.That(command.CanExecute(parameterString), Is.True);

            // Check convertible parameter.
            Assert.That(command.CanExecute(parameterAsInt), Is.True);
            Assert.That(actionPerformed, Is.True);

            Assert.That(executeActionParam, Is.EqualTo(parameterString));
        }
コード例 #3
0
ファイル: RelayCommandTest.cs プロジェクト: jprofi/MSProjects
        public void TestRelayCommandNoParamNoCanExecute()
        {
            bool actionPerformed = false;

            BaseCommand command = new RelayCommand(
                () => { actionPerformed = true; });

            Assert.That(command.HasCanExecuteFunction, Is.False);
            Assert.That(command.CanExecute(null), Is.True);
            command.Execute(null);

            Assert.That(command.CanExecute(null), Is.True);
            Assert.That(actionPerformed, Is.True);
        }