public void Find_registered_type_by_alias() { var SUT = new ParserRegistration(GetBaselineTestTypes(), GetHelpTextForTest); var result = SUT.GetTargetType("test03"); AssertTypeResult(typeof(ParserRegTest03), result); }
public void Find_registered_type_by_name_where_type_name_provided_does_not_match_the_case_of_the_registered_type_name() { var SUT = new ParserRegistration(GetBaselineTestTypes(), GetHelpTextForTest); var result = SUT.GetTargetType("parserregtest02"); AssertTypeResult(typeof(ParserRegTest02), result); }
public void Find_Registered_Type_By_Type_Name_Where_Type_Name_Is_Not_Registered() { var SUT = new ParserRegistration(GetBaselineTestTypes().Where(t => t.Name != "ParserRegTest01").ToArray(), GetHelpTextForTest); var result = SUT.GetTargetType("ParserRegTest01"); AssertTypeResult(null, result); }
public void Construct_with_types_that_have_conflicting_alias_names() { var types = GetBaselineTestTypes().ToList(); types.Add(typeof(ParserRegTest02_Dupe)); var SUT = new ParserRegistration(types.ToArray(), GetHelpTextForTest); var result = SUT.GetTargetType("test02"); Assert.IsNull(result); }
private ParserRunner GetMultiTypesParser(string[] args, ParserRegistration registration) { Debug.Assert(args.Any()); var verb = args[0]; // if the first arg is not a verb - throw // if (verb.StartsWith(ParserRunner.ArgumentPrefixes)) { throw new MissingVerbException(); } if (!verb.Contains(s_delimiters)) { throw new MultiParserMissingClassNameException(); } var parts = verb.Split(s_delimiters, StringSplitOptions.RemoveEmptyEntries); if (parts.Length != 2) { throw new InvalidVerbException(); } var typeNameOrAlias = parts[0]; args[0] = args[0].Substring(typeNameOrAlias.Length + 1); var matchingType = registration.GetTargetType(typeNameOrAlias); if (matchingType == null) { throw new UnknownParserTypeException(typeNameOrAlias); } return new ParserRunner(matchingType, registration, HelpGenerator); }
public void Find_registered_type_by_type_name() { var SUT = new ParserRegistration(GetBaselineTestTypes(), GetHelpTextForTest); var result = SUT.GetTargetType("ParserRegTest02"); AssertTypeResult(typeof (ParserRegTest02), result); }
public void Find_registered_type_by_name_where_type_name_provided_does_not_match_the_case_of_the_registered_type_name() { var SUT = new ParserRegistration(GetBaselineTestTypes(), GetHelpTextForTest); var result = SUT.GetTargetType("parserregtest02"); AssertTypeResult(typeof (ParserRegTest02), result); }