public void AsyncCommandImplementation()
        {
            var generated = new GenerateAsyncCommands();

            Assert.IsNotNull(generated.GetType().GetProperty("WithNoArgCommand"));
            Assert.IsNotNull(generated.GetType().GetProperty("WithArgCommand"));
            Assert.IsNotNull(generated.GetType().GetProperty("WithNullableArgCommand"));

            Assert.IsNull(generated.GetType().GetProperty("With2ArgsCommand"));
            Assert.IsNull(generated.GetType().GetProperty("ReturnNoTaskCommand"));
            Assert.IsNull(generated.GetType().GetProperty("SomeMethodCommand"));
        }
        public void ArgumentTypeForAsyncCommand()
        {
            var generated = new GenerateAsyncCommands();

            var noArgumentType = generated.WithNoArgCommand.GetType();

            Assert.IsEmpty(noArgumentType.GetGenericArguments());
            var expectedType = typeof(AsyncCommand);

            Assert.AreEqual(expectedType, noArgumentType);

            var intArgumentType = generated.WithArgCommand.GetType().GetGenericArguments()[0];
            var intExpectedType = typeof(int);

            Assert.AreEqual(intExpectedType, intArgumentType);

            var nullableIntArgumentType = generated.WithNullableArgCommand.GetType().GetGenericArguments()[0];
            var nullableIntExpectedType = typeof(int?);

            Assert.AreEqual(nullableIntExpectedType, nullableIntArgumentType);
        }
        public void CallRequiredMethodForAsyncCommand()
        {
            var generated = new GenerateAsyncCommands();

            var method         = GetFieldValue <Func <int, Task>, AsyncCommand <int> >(generated.MyAsyncCommand, "executeMethod");
            var expectedMethod = generated.GetType().GetMethod("Method");

            Assert.AreEqual(expectedMethod, method.Method);

            var canMethod         = GetFieldValue <Func <int, bool>, AsyncCommand <int> >(generated.MyAsyncCommand, "canExecuteMethod");
            var expectedCanMethod = generated.GetType().GetMethod("CanDoIt");

            Assert.AreEqual(expectedCanMethod, canMethod.Method);

            var useCommandManager         = GetFieldValue <bool, AsyncCommand <int> >(generated.MyAsyncCommand, "useCommandManager");
            var expectedUseCommandManager = true;

            Assert.AreEqual(expectedUseCommandManager, useCommandManager);

            var allowMultipleExecution         = generated.MyAsyncCommand.AllowMultipleExecution;
            var expectedAllowMultipleExecution = false;

            Assert.AreEqual(expectedAllowMultipleExecution, allowMultipleExecution);

            useCommandManager         = GetFieldValue <bool, AsyncCommand>(generated.AsyncCommandWithoutCommandManager, "useCommandManager");
            expectedUseCommandManager = false;
            Assert.AreEqual(expectedUseCommandManager, useCommandManager);

            allowMultipleExecution         = generated.AllowMultipleExecutionCommand.AllowMultipleExecution;
            expectedAllowMultipleExecution = true;
            Assert.AreEqual(expectedAllowMultipleExecution, allowMultipleExecution);

            var canExecuteMethod = GetFieldValue <Func <int, bool>, AsyncCommand>(generated.GenericTaskCommand, "canExecuteMethod");

            Assert.IsNull(canExecuteMethod);
        }