public void Constructor_Default_ReturnsICommand()
        {
            var func    = Execute.Create();
            var command = Command.Create(func);

            Assert.IsAssignableFrom <ICommand>(command);
        }
Example #2
0
        public void Constructor_Default_ReturnsIAsyncCommandGeneric()
        {
            var func    = Execute.Create <string>();
            var command = Command.Create(func);

            Assert.IsAssignableFrom <IAsyncCommand <string> >(command);
        }
        public void CanExecute_NotNullDelegate_ReturnsExpectedValue(object parameter, bool expected)
        {
            var func = Execute.Create<string>();
            var command = Command.Create(func, _ => expected);

            Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, parameter, expected);
        }
Example #4
0
        public void CanExecute_WithNullParameter_ReturnsTrue()
        {
            var func    = Execute.Create();
            var command = Command.Create(func);

            Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, null, true);
        }
Example #5
0
        public void CanExecute_NotNullDelegate_ReturnsExpectedValue(bool expected)
        {
            var func    = Execute.Create();
            var command = Command.Create(func, () => expected);

            Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, null, expected);
        }
        public void CanExecuteChanged_ExecuteWasFinished_RisesOnce()
        {
            var func    = Execute.Create <string>();
            var command = Command.Create(func);

            Assert_CanExecuteChanged_AfterExecute_RisesOnce(command);
        }
Example #7
0
        public void CanExecute_WithUnsupportedParameters_IgnoresParameter(object parameter)
        {
            var func    = Execute.Create();
            var command = Command.Create(func);

            Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, parameter, true);
        }
        public void CanExecute_DefaultWithParameters_ReturnsTrue(object parameter)
        {
            var func = Execute.Create<string>();
            var command = Command.Create(func);

            Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, parameter, true);
        }
Example #9
0
        public void Constructor_Default_ReturnsIRaisableCanExecute()
        {
            var func    = Execute.Create <string>();
            var command = Command.Create(func);

            Assert.IsAssignableFrom <IRaisableCanExecute>(command);
        }
        public void CanExecute_DefaultWithParameters_WhenTypesMismatch_ReturnsFalse()
        {
            var func = Execute.Create<string>();
            var command = Command.Create(func);

            Assert_CanExecute_WithParameter_ReturnsExpectedValue(command, 123, false);
        }
Example #11
0
        public async Task ExecuteAsync_AsyncWithException_ThrowsException(string parameter)
        {
            var func    = Execute.WithException <string>();
            var command = Command.Create(func);

            await Assert.ThrowsAsync <InvalidOperationException>(() => command.ExecuteAsync(parameter));
        }
Example #12
0
        public async Task ExecuteAsync_AsyncWithException_ThrowsException()
        {
            var func    = Execute.WithException();
            var command = Command.Create(func);

            await Assert.ThrowsAsync <InvalidOperationException>(() => command.ExecuteAsync(null));
        }
        public void Execute_CanExecuteFalse_DoNotExecutes(string parameter)
        {
            var func    = Execute.Create <string>();
            var command = Command.Create(func, _ => false);

            command.Execute(parameter);

            func.DidNotReceive().Invoke(parameter);
        }
Example #14
0
        public void Execute_CanExecuteFalse_DoesNotExecute()
        {
            var func    = Execute.Create();
            var command = Command.Create(func, () => false);

            command.Execute(null);

            func.DidNotReceive().Invoke();
        }
Example #15
0
        public void Execute_CanExecuteTrue_ExecutesOneTime()
        {
            var func    = Execute.Create();
            var command = Command.Create(func, () => true);

            command.Execute(null);

            func.Received(1).Invoke();
        }
Example #16
0
        public void Execute_WithNotNullParameter_IgnoresParameter(object parameter)
        {
            var func    = Execute.Create();
            var command = Command.Create(func);

            command.Execute(parameter);

            func.Received(1).Invoke();
        }
Example #17
0
        public void Execute_CalledOneTime_ExecutesOneTime()
        {
            var func    = Execute.Create();
            var command = Command.Create(func);

            command.Execute(null);

            func.Received(1).Invoke();
        }
        public void Execute_AsICommand_Executes(string parameter)
        {
            var func    = Execute.Create <string>();
            var command = Command.Create(func) as ICommand;

            command.Execute(parameter);

            func.Received(1).Invoke(parameter);
        }
Example #19
0
        public void Execute_AsyncWithException_ExecutesWithoutException()
        {
            var func    = Execute.WithException();
            var command = Command.Create(func);

            command.Execute(null);

            func.Received(1).Invoke();
        }
Example #20
0
        public async Task ExecuteAsync_CalledOneTime_ExecutesOneTime(string parameter)
        {
            var func    = Execute.Create <string>();
            var command = Command.Create(func);

            await command.ExecuteAsync(parameter);

            await func.Received(1).Invoke(parameter);
        }
Example #21
0
        public async Task ExecuteAsync_WithUnsupportedParameter_IgnoresParameter(object parameter)
        {
            var func    = Execute.Create();
            var command = Command.Create(func);

            await command.ExecuteAsync(parameter);

            await func.Received(1).Invoke();
        }
Example #22
0
        public async Task ExecuteAsync_CalledOneTime_ExecutesOneTime()
        {
            var func    = Execute.Create();
            var command = Command.Create(func);

            await command.ExecuteAsync(null);

            await func.Received(1).Invoke();
        }
        public void Execute_CanExecuteTrue_ExecutesOneTime(string parameter)
        {
            var func    = Execute.Create <string>();
            var command = Command.Create(func, _ => true);

            command.Execute(parameter);

            func.Received(1).Invoke(parameter);
        }
        public void Execute_AsyncWithException_ExecutesWithoutException(string parameter)
        {
            var func    = Execute.WithException <string>();
            var command = Command.Create(func);

            command.Execute(parameter);

            func.Received(1).Invoke(parameter);
        }
        public void Execute_AsICommandGenericWithNullableStruct_Executes(int?parameter)
        {
            var func    = Execute.Create <int?>();
            var command = Command.Create(func) as ICommand <int?>;

            command.Execute(parameter);

            func.Received(1).Invoke(parameter);
        }
        public void CanExecute_WhileExecuting_ReturnsFalse()
        {
            var tcs = new TaskCompletionSource<bool>();
            var func = Execute.FromSource<string>(tcs);
            var command = Command.Create(func);

            Assert_CanExecute_AfterExecuteWithParameter_ReturnsExpectedValue(command, null, false);

            tcs.SetResult(true);
        }
        public void Execute_SyncCallTwoTimes_ExecutesTwoTimes(string parameter)
        {
            var func    = Execute.Create <string>();
            var command = Command.Create(func);

            command.Execute(parameter);
            command.Execute(parameter);

            func.Received(2).Invoke(parameter);
        }
Example #28
0
        public void Execute_SyncCallTwoTimes_ExecutesTwoTimes()
        {
            var func    = Execute.Create();
            var command = Command.Create(func);

            command.Execute(null);
            command.Execute(null);

            func.Received(2).Invoke();
        }
        public void Execute_WithUnsupportedParameterType_IgnoresParameter <TCommand, TParameter>(
            TCommand commandType,
            TParameter parameter)
        {
            var func    = Execute.Create <TCommand>();
            var command = Command.Create(func);

            command.Execute(parameter);

            func.DidNotReceive().Invoke(Arg.Any <TCommand>());
        }
Example #30
0
        public void Execute_AsyncCallSeveralTimes_ExecutesOneTime()
        {
            var tcs     = new TaskCompletionSource <bool>();
            var func    = Execute.FromSource(tcs);
            var command = Command.Create(func);

            command.Execute(null);
            command.Execute(null);
            command.Execute(null);

            func.Received(1).Invoke();

            tcs.SetResult(true);
        }