Ejemplo n.º 1
0
        public void Create_Asynchronous_Value_NoCommandParameter_MutableState()
        {
            IAsyncCommandSlim command = Command.Create(() => new ValueTask(), () => false);

            Assert.IsType <AsyncRelayCommandSlim>(command);
            Assert.False(command.CanExecute());
        }
Ejemplo n.º 2
0
        public void Create_Asynchronous_Value_StronglyTypedCommandParameter_DefaultState()
        {
            IAsyncCommandSlim <int> command = Command.Create <int>(_ => new ValueTask());

            Assert.IsType <AsyncRelayCommandSlim <int> >(command);
            Assert.True(command.CanExecute(240));
        }
Ejemplo n.º 3
0
        public void Create_Asynchronous_Value_NoCommandParameter_DefaultState()
        {
            IAsyncCommandSlim command = Command.Create(() => new ValueTask());

            Assert.IsType <AsyncRelayCommandSlim>(command);
            Assert.True(command.CanExecute());
        }
Ejemplo n.º 4
0
        public static async ValueTask <bool> TryExecuteAsync <T>(this IAsyncCommandSlim <T> command, T parameter)
        {
            if (command.CanExecute(parameter))
            {
                await command.ExecuteAsync(parameter);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        public static async ValueTask <bool> TryExecuteAsync(this IAsyncCommandSlim command)
        {
            if (command.CanExecute())
            {
                await command.ExecuteAsync();

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