public static void GetCommandRuleMetodHasCommandWithNonAllowedDuplicateAttributesParametersThrowMissingCommandParameterAttributeExceptionUnitTest() { CommandRuleProvider target = new CommandRuleProvider(); Assert.Throws <DuplicateCommandParameterAttributeException>(() => { target.GetCommandRule(typeof(TestCommands0).GetMethodEx("CommandWithNonAllowedDuplicateAttributesParameters")); }); }
public static void GetCommandRuleMetodHasValidCommandWithOneParameterWithoutParameterAttributeThrowMissingCommandParameterAttributeExceptionUnitTest() { CommandRuleProvider target = new CommandRuleProvider(); Assert.Throws <MissingCommandParameterAttributeException>(() => { target.GetCommandRule(typeof(TestCommands0).GetMethodEx("CommandWithOneParameterWithoutParameterAttribute")); }); }
GetCommandRuleMetodHasCommandWithIncorrectlyOrderedParametersThrowMissingCommandParameterAttributeExceptionUnitTest () { CommandRuleProvider target = new CommandRuleProvider(); Assert.Throws <RequiredParameterFoundAfterOptionalParameterExecption>(() => { target.GetCommandRule(typeof(TestCommands0).GetMethodEx("CommandWithIncorrectlyOrderedParameters")); }); }
public static void GetCommandRuleMetodHasCommandWithTwoRequiredParameterAndOneOptionalParameterVerifyCommandRuleSucessUnitTest() { CommandRuleProvider target = new CommandRuleProvider(); string expectedCommandName = "CommandWithTwoRequiredParameterAndOneOptionalParameter"; CommandRule commandRule = target.GetCommandRule(typeof(TestCommands0).GetMethodEx(expectedCommandName)); Assert.AreEqual(expectedCommandName, commandRule.Command.Name); Assert.AreEqual(2, commandRule.Command.RequiredParameters.Count); Assert.AreEqual(1, commandRule.Command.OptionalParameters.Count); //Console.WriteLine(commandRule.Help()); }
public static void GetCommandRuleWithOnlyDescriptionAndNoSummaryDefinedTest() { var target = new CommandRuleProvider(); string expectedCommandName = "CommandWithOnlyDescriptionAndNoSummaryDefined"; var actualCommandRule = target.GetCommandRule(typeof(TestCommands9).GetMethodEx(expectedCommandName)); Assert.AreEqual(expectedCommandName, actualCommandRule.Command.Name); Assert.AreEqual(0, actualCommandRule.Command.RequiredParameters.Count); Assert.AreEqual(0, actualCommandRule.Command.OptionalParameters.Count); var expectedDescription = "Command with only description defined. Summary should the be set to the same as the description."; var epectedSummary = "Command with only description defined. Summary should the be set to the same as the description."; Assert.AreEqual(expectedDescription, actualCommandRule.Command.Description); Assert.AreEqual(epectedSummary, actualCommandRule.Command.Summary); }
public static void GetCommandRuleWithBothDescriptionAndSummaryDefinedTest() { var target = new CommandRuleProvider(); string expectedCommandName = "CommandWithBothDescriptionAndSummaryDefined"; var actualCommandRule = target.GetCommandRule(typeof(TestCommands9).GetMethodEx(expectedCommandName)); Assert.AreEqual(expectedCommandName, actualCommandRule.Command.Name); Assert.AreEqual(0, actualCommandRule.Command.RequiredParameters.Count); Assert.AreEqual(0, actualCommandRule.Command.OptionalParameters.Count); var expectedDescription = "Command with both summary and description defined"; var epectedSummary = "Summary of command"; Assert.AreEqual(expectedDescription, actualCommandRule.Command.Description); Assert.AreEqual(epectedSummary, actualCommandRule.Command.Summary); }
public static void GetCommandRulesHelpProviderTest() { var target = new CommandRuleProvider(); var actualCommandRules = target.GetCommandRules(typeof(TestCommands9)); var messenger = new StringMessenger(); var helpProvider = new HelpProvider(new Func <IMessenger>(() => messenger)); helpProvider.ShowHelp(actualCommandRules, null, new ApplicationInfo()); Assert.Contains("CommandWithBothDescriptionAndSummaryDefined Summary of command", messenger.Message.ToString()); Assert.Contains("CommandWithOnlyDescriptionAndNoSummaryDefined Command with only", messenger.Message.ToString()); Assert.Contains("CommandWithTwoRequiredParameterAndOneOptionalParameter Summary of", messenger.Message.ToString()); Assert.Contains("CommandWithBothDescriptionAndSummaryDefined Command with both", messenger.Message.ToString()); Assert.Contains("CommandWithOnlyDescriptionAndNoSummaryDefined Command with only", messenger.Message.ToString()); Assert.Contains("CommandWithTwoRequiredParameterAndOneOptionalParameter Command with two", messenger.Message.ToString()); }
public static void GetCommandRulesTargetTypeWithFiveCommands() { CommandRuleProvider target = new CommandRuleProvider(); List <CommandRule> actual = target.GetCommandRules(typeof(FiveTestCommands)); Assert.AreEqual(5, actual.Count); Assert.IsTrue(actual[0].Command.Name == "Command1", "Name of command 1"); Assert.IsTrue(actual[1].Command.Name == "Command2", "Name of command 2"); Assert.IsTrue(actual[2].Command.Name == "Command3", "Name of command 3"); Assert.IsTrue(actual[3].Command.Name == "Command4", "Name of command 4"); Assert.IsTrue(actual[4].Command.Name == "Command5", "Name of command 5"); Assert.IsTrue(actual[0].Command.Description == "Command 1 description", "Description of command 1"); Assert.IsTrue(actual[1].Command.Description == "Command 2 description", "Description of command 2"); Assert.IsTrue(actual[2].Command.Description == "Command 3 description", "Description of command 3"); Assert.IsTrue(actual[3].Command.Description == "Command 4 description", "Description of command 4"); Assert.IsTrue(actual[4].Command.Description == "Command 5 description", "Description of command 5"); }
public static void GetCommandRuleMetodHasNoCommandAttributeThrowCommandMehtodNotStaticExceptionUnitTest() { CommandRuleProvider target = new CommandRuleProvider(); target.GetCommandRule(typeof(TestCommands0).GetMethodEx("CommandNotStatic")); }
public SocketServer() : base(new SocketFilterFactory()) { CommandRuleProvider = new CommandRuleProvider(); this.Setup(2020); }