public void Returns_empty_for_non_describably_matcher_when_specification_is_for_an_incompatible_type() { var matcher = new MatcherNotSupportingDescribe(); var subject = new ArgumentSpecification(typeof(int), matcher); var result = subject.DescribeNonMatch("not an int"); Assert.That(result, Is.Empty); }
public void Returns_the_desription_when_the_matcher_supports_describing_non_matches() { var matcher = new MatcherSupportingDescribe(); var subject = new ArgumentSpecification(typeof(object), matcher); var result = subject.DescribeNonMatch(new object()); Assert.That(result, Is.EqualTo(MatcherSupportingDescribe.Description)); }
public void Returns_empty_when_matcher_does_not_support_describing_non_matches() { var matcher = new MatcherNotSupportingDescribe(); var subject = new ArgumentSpecification(typeof(object), matcher); var result = subject.DescribeNonMatch(new object()); Assert.That(result, Is.Empty); }
public static T Match <T>(Action <T> action) { var matcher = new AssertionMatcher <T>(action); var innerArgumentSpecification = new ArgumentSpecification(typeof(T), matcher); var fluentArgumentSpecification = new FluentArgumentSpecification(innerArgumentSpecification, matcher); substitutionContextAtStart.EnqueueArgumentSpecification(fluentArgumentSpecification); return(default(T)); }
public void Returns_arg_incompatible_without_calling_describable_matcher_when_specification_is_for_an_incompatible_type() { var matcher = new MatcherSupportingDescribe(); var subject = new ArgumentSpecification(typeof(int), matcher); var result = subject.DescribeNonMatch("not an int"); var expectedResult = string.Format("Expected an argument compatible with type {0}. Actual type was {1}.", typeof(int), typeof(string)); Assert.That(result, Is.EqualTo(expectedResult)); }
public static ArgumentDataMatches ParseCommandInput(ArgumentSpecification argumentSpec, ref string input, bool optArgsFirst = true) { ArgumentDataMatches matches = new ArgumentDataMatches(); input = RemoveMultipleSpaces(input); if (optArgsFirst) { matches.OptArgsMatches = CommandRecognizer.Recognize(ref input, argumentSpec.OptArgs.Values); matches.ArgsMatches = CommandRecognizer.Recognize(ref input, argumentSpec.Args.Values); } else { matches.ArgsMatches = CommandRecognizer.Recognize(ref input, argumentSpec.Args.Values); matches.OptArgsMatches = CommandRecognizer.Recognize(ref input, argumentSpec.OptArgs.Values); } return(matches); }
private static ref T EnqueueSpecFor <T>(IArgumentMatcher argumentMatcher) { var argumentSpecification = new ArgumentSpecification(typeof(T), argumentMatcher); return(ref EnqueueArgSpecification <T>(argumentSpecification)); }