public void ValidateIntegerRule_ShouldReturnFalse(string input) { ILexicalRules IntegerValidator = new IntegerRule(); bool result = IntegerValidator.validate(input); Assert.False(result); }
public void IntegerRuleValidatesInputProperly() { var rule = new IntegerRule(); Assert.IsFalse(rule.Validate("blah", CultureInfo.InvariantCulture).IsValid); Assert.IsFalse(rule.Validate("123.123", CultureInfo.InvariantCulture).IsValid); Assert.IsTrue(rule.Validate("123", CultureInfo.InvariantCulture).IsValid); }
public void ShouldStringifyGivenIntegerWhenApplyIsCalled() { var input = Any.Integer(); var outputBuilder = Substitute.For <IOutputBuilder>(); var rule = new IntegerRule(Any.Boolean(), Any.InstanceOf <IRule>(), outputBuilder); rule.Apply(input); outputBuilder.Received().Append(input.ToString()); }
public void ShouldNotCallSuccessorWhenApplyIsCalledAndIsBreakable() { var input = Any.Integer(); var successor = Substitute.For <IRule>(); var outputBuilder = Substitute.For <IOutputBuilder>(); var rule = new IntegerRule(true, successor, outputBuilder); rule.Apply(input); outputBuilder.Received().Append(input.ToString()); successor.DidNotReceive().Apply(input); }
public bool IsGrammarCorrect() { AttrRef attrRef = new AttrRef(text, declarations); if (attrRef.IsGrammarCorrect()) { refType = attrRef.refType; return(true); } ProglineSynonym proglineSynonym = new ProglineSynonym(text, declarations); if (proglineSynonym.IsGrammarCorrect()) { refType = RefType.Integer; return(true); } BracesIdent bracesIdent = new BracesIdent(); if (bracesIdent.validate(text)) { refType = RefType.String; return(true); } IntegerRule integerRule = new IntegerRule(); if (integerRule.validate(text)) { refType = RefType.Integer; return(true); } return(false); }