Ejemplo n.º 1
0
        public async Task _ExecutionSuccessful([NotNull] CommandBaseTests.TestArgs <AsyncCommand> args)
        {
            Assert.AreEqual(args.IsCancelCommandEnabled, args.Command.Options.IsCancelCommandEnabled);
            Assert.AreEqual(args.CanExecute, args.Command.CanExecute());
            Assert.AreEqual(args.CanExecute, ((ICommand)args.Command).CanExecute(null));

            args.UpdateReentrancyContainer(3);

            Assert.IsNull(args.Command.RunningExecution);
            Assert.IsNull(args.Command.CompletedExecution);

            await args.Command.Execute();

            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Done, true, false);

            ((ICommand)args.Command).Execute(null);
            while (args.Command.RunningExecution != null)
            {
                await Task.Delay(100);
            }
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Done, true, false);

            args.Command.StartExecute();
            while (args.Command.RunningExecution != null)
            {
                await Task.Delay(100);
            }
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Done, true, false);

            CommandBaseTests.CanExecuteChanged(args.Command);
        }
Ejemplo n.º 2
0
        public async Task _ExecutionFailed([NotNull] CommandBaseTests.TestArgs <AsyncCommand <int> > args)
        {
            args.UpdateReentrancyContainer(3);

            Assert.IsNull(args.Command.RunningExecution);
            Assert.IsNull(args.Command.CompletedExecution);

            await args.Command.Execute(0);

            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Faulted, false, true);

            ((ICommand)args.Command).Execute(0);
            while (args.Command.RunningExecution != null)
            {
                await Task.Delay(100);
            }
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Faulted, false, true);

            args.Command.StartExecute(0);
            while (args.Command.RunningExecution != null)
            {
                await Task.Delay(100);
            }
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Faulted, false, true);

            CommandBaseTests.CanExecuteChanged(args.Command);
        }
Ejemplo n.º 3
0
        public async Task _ExecutionSuccessful_ReferenceType([NotNull] CommandBaseTests.TestArgs <AsyncCommand <string> > args)
        {
            await _ExecutionSuccessful(args, 2);

            Assert.IsFalse(((ICommand)args.Command).CanExecute(0));
            Assert.AreEqual(args.CanExecute, ((ICommand)args.Command).CanExecute(null));
            Assert.AreEqual(args.CanExecute, ((ICommand)args.Command).CanExecute(""));
        }
Ejemplo n.º 4
0
        public void _ExecutionSuccessful_NullableValueType([NotNull] CommandBaseTests.TestArgs <Command <int?> > args)
        {
            _ExecutionSuccessful(args, 2);

            Assert.AreEqual(args.CanExecute, ((ICommand)args.Command).CanExecute(0));
            Assert.AreEqual(args.CanExecute, ((ICommand)args.Command).CanExecute(null));
            Assert.IsFalse(((ICommand)args.Command).CanExecute(""));
        }
Ejemplo n.º 5
0
        public void _ExecutionFailed([NotNull] CommandBaseTests.TestArgs <Command <int> > args)
        {
            args.UpdateReentrancyContainer(2);

            Assert.IsNull(args.Command.RunningExecution);
            Assert.IsNull(args.Command.CompletedExecution);

            args.Command.Execute(0);
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Faulted, false, true);

            ((ICommand)args.Command).Execute(0);
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Faulted, false, true);

            CommandBaseTests.CanExecuteChanged(args.Command);
        }
Ejemplo n.º 6
0
        static async Task _ExecutionSuccessful <T>([NotNull] CommandBaseTests.TestArgs <AsyncCommand <T> > args, int nonGenericExecutionCount)
        {
            Assert.AreEqual(args.IsCancelCommandEnabled, args.Command.Options.IsCancelCommandEnabled);
            Assert.AreEqual(args.CanExecute, args.Command.CanExecute(default(T)));

            args.UpdateReentrancyContainer(1 + nonGenericExecutionCount + 1);

            Assert.IsNull(args.Command.RunningExecution);
            Assert.IsNull(args.Command.CompletedExecution);

            await args.Command.Execute(default(T));

            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Done, true, false);

            ((ICommand)args.Command).Execute(0);
            while (args.Command.RunningExecution != null)
            {
                await Task.Delay(100);
            }
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Done, true, false);

            ((ICommand)args.Command).Execute(null);
            while (args.Command.RunningExecution != null)
            {
                await Task.Delay(100);
            }
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Done, true, false);

            ((ICommand)args.Command).Execute("");
            while (args.Command.RunningExecution != null)
            {
                await Task.Delay(100);
            }
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Done, true, false);

            args.Command.StartExecute(default(T));
            while (args.Command.RunningExecution != null)
            {
                await Task.Delay(100);
            }
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Done, true, false);

            CommandBaseTests.CanExecuteChanged(args.Command);
        }
Ejemplo n.º 7
0
        public void _ExecutionSuccessful([NotNull] CommandBaseTests.TestArgs <Command> args)
        {
            Assert.AreEqual(args.IsCancelCommandEnabled, args.Command.Options.IsCancelCommandEnabled);
            Assert.AreEqual(args.CanExecute, args.Command.CanExecute());
            Assert.AreEqual(args.CanExecute, ((ICommand)args.Command).CanExecute(null));

            args.UpdateReentrancyContainer(2);

            Assert.IsNull(args.Command.RunningExecution);
            Assert.IsNull(args.Command.CompletedExecution);

            args.Command.Execute();
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Done, true, false);

            ((ICommand)args.Command).Execute(null);
            CommandBaseTests.AssertExecutionsAfterCompletion(args, CompletedCommandExecutionState.Done, true, false);

            CommandBaseTests.CanExecuteChanged(args.Command);
        }