Example #1
0
        public void Create_Bounded_Value_StronglyTypedCommandParameter_MutableState()
        {
            IBoundedCommandSlim <int> command = Command.Create <int>(_ => new ValueTask(), _ => false, 1);

            Assert.IsType <BoundedRelayCommandSlim <int> >(command);
            Assert.False(command.CanExecute(240));
            Assert.Equal(1, command.MaxCount);
        }
Example #2
0
        public void Create_Bounded_Value_NoCommandParameter_MutableState()
        {
            IBoundedCommandSlim command = Command.Create(() => new ValueTask(), () => false, 1);

            Assert.IsType <BoundedRelayCommandSlim>(command);
            Assert.False(command.CanExecute());
            Assert.Equal(1, command.MaxCount);
        }
Example #3
0
        public static async ValueTask <bool> TryExecuteAsync <T>(this IBoundedCommandSlim <T> command, T parameter)
        {
            if (command.CanExecute(parameter))
            {
                await command.ExecuteAsync(parameter);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        public static async ValueTask <bool> TryExecuteAsync(this IBoundedCommandSlim command)
        {
            if (command.CanExecute())
            {
                await command.ExecuteAsync();

                return(true);
            }
            else
            {
                return(false);
            }
        }