public void CallRequiredMethodForCommand() { var generated = new GenerateCommands(); var executeMethodWithNoArg = GetFieldValue <Action <int?>, DelegateCommand <int?> >(generated.WithNullableArgCommand, "executeMethod"); var expectedExecuteMethodWithNoArg = generated.GetType().GetMethod("WithNullableArg"); Assert.AreEqual(expectedExecuteMethodWithNoArg, executeMethodWithNoArg.Method); var method = GetFieldValue <Action <int>, DelegateCommand <int> >(generated.Command, "executeMethod"); var expectedMethod = generated.GetType().GetMethod("Method"); Assert.AreEqual(expectedMethod, method.Method); var canMethod = GetFieldValue <Func <int, bool>, DelegateCommand <int> >(generated.Command, "canExecuteMethod"); var expectedCanMethod = generated.GetType().GetMethod("CanDoIt"); Assert.AreEqual(expectedCanMethod, canMethod.Method); var useCommandManager = GetFieldValue <bool, DelegateCommand <int> >(generated.Command, "useCommandManager"); var expectedUseCommandManager = true; Assert.AreEqual(expectedUseCommandManager, useCommandManager); useCommandManager = GetFieldValue <bool, DelegateCommand>(generated.CommandWithoutCommandManager, "useCommandManager"); expectedUseCommandManager = false; Assert.AreEqual(expectedUseCommandManager, useCommandManager); var canExecuteMethod = GetFieldValue <Func <int, bool>, DelegateCommand>(generated.CommandWithoutCommandManager, "canExecuteMethod"); Assert.IsNull(canExecuteMethod); }
public void CommandImplementation() { var generated = new GenerateCommands(); 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("ReturnNoVoidCommand")); Assert.IsNull(generated.GetType().GetProperty("SomeMethodCommand")); }