public void ShouldReturnNullWhenAtTheEndOfTheTokenizer() { var stringTokenizer = new StringTokenizer(string.Empty); var mockMatchKeyword = new MockMatchKeyword(TokenType.Word, "key"); var token = mockMatchKeyword.CallImplementation(stringTokenizer); Assert.IsNull(token); }
public void ShouldSetTheValueOfTheToken() { var stringTokenizer = new StringTokenizer("key"); var mockMatchKeyword = new MockMatchKeyword(TokenType.Word, "key"); var token = mockMatchKeyword.CallImplementation(stringTokenizer); Assert.AreEqual("key", token.TokenValue); }
public void ShouldReturnNullWhenTheKeywordIsNotFound() { var stringTokenizer = new StringTokenizer("kee"); var mockMatchKeyword = new MockMatchKeyword(TokenType.Word, "key"); var token = mockMatchKeyword.CallImplementation(stringTokenizer); Assert.IsNull(token); }
public void ShouldMatchAWordAtTheEndOfTheTokenizerWhenAllowAsSubstringIsFalse() { var stringTokenizer = new StringTokenizer("key"); var mockMatchKeyword = new MockMatchKeyword(TokenType.Word, "key"); mockMatchKeyword.AllowAsSubString = false; var token = mockMatchKeyword.CallImplementation(stringTokenizer); Assert.IsNotNull(token); }
public void ShouldMatchASubstringWhenAllowAsSubstringIsTrue() { var stringTokenizer = new StringTokenizer("keyword"); var mockMatchKeyword = new MockMatchKeyword(TokenType.Word, "key"); mockMatchKeyword.AllowAsSubString = true; var token = mockMatchKeyword.CallImplementation(stringTokenizer); Assert.IsNotNull(token); }
public void ShouldCaptureCurrentTheLocation() { var stringTokenizer = new Mock <StringTokenizer>("key") { CallBase = true }; var mockMatchKeyword = new MockMatchKeyword(TokenType.Word, "key"); mockMatchKeyword.CallImplementation(stringTokenizer.Object); stringTokenizer.Verify(t => t.GetCurrentLocation(), Times.Once); }
public void ShouldMatchAWordTerminatedByASpecialCharacterWhenAllowAsSubstringIsFalse() { var stringTokenizer = new StringTokenizer("key, word"); var mockMatchKeyword = new MockMatchKeyword(TokenType.Word, "key"); mockMatchKeyword.AllowAsSubString = false; mockMatchKeyword.SpecialCharacters = new List <MatchKeyword> { new MatchKeyword(TokenType.Word, ",") }; var token = mockMatchKeyword.CallImplementation(stringTokenizer); Assert.IsNotNull(token); }
public void ShouldCreateATokenFromCurrentTheLoction() { var tokenLocation = new Mock <ITokenLocation>(MockBehavior.Default); var stringTokenizer = new Mock <StringTokenizer>("key") { CallBase = true }; stringTokenizer.Setup(t => t.GetCurrentLocation()).Returns(tokenLocation.Object); var mockMatchKeyword = new MockMatchKeyword(TokenType.Word, "key"); mockMatchKeyword.CallImplementation(stringTokenizer.Object); tokenLocation.Verify(l => l.CreateToken(It.IsAny <TokenType>(), It.IsAny <string>()), Times.Once); }