public void ShouldSetTheValueOfTheToken() { var stringTokenizer = new StringTokenizer(" "); var mockMatchWhiteSpace = new MockMatchWhiteSpace(); var token = mockMatchWhiteSpace.CallImplementation(stringTokenizer); Assert.AreEqual(" ", token.TokenValue); }
public void ShouldTreatASpaceAsWhiteSpace() { var stringTokenizer = new StringTokenizer(" "); var mockMatchWhiteSpace = new MockMatchWhiteSpace(); var token = mockMatchWhiteSpace.CallImplementation(stringTokenizer); Assert.IsNotNull(token); }
public void ShouldReturnNullWhenNoWhiteSpaceIsFound() { var stringTokenizer = new StringTokenizer("123"); var mockMatchWhiteSpace = new MockMatchWhiteSpace(); var token = mockMatchWhiteSpace.CallImplementation(stringTokenizer); Assert.IsNull(token); }
public void ShouldConsumeAllAvailableWhiteSpaceFromTokenizer() { var stringTokenizer = new StringTokenizer(" \t\t \r\n "); var mockMatchWhiteSpace = new MockMatchWhiteSpace(); var token = mockMatchWhiteSpace.CallImplementation(stringTokenizer); Assert.IsNotNull(token); Assert.IsTrue(stringTokenizer.IsAtEnd()); }
public void ShouldReturnNullWhenAtTheEndOfTheTokenizer() { var stringTokenizer = new Mock <StringTokenizer>(string.Empty); stringTokenizer.Setup(t => t.IsAtEnd()).Returns(true); var mockMatchWhiteSpace = new MockMatchWhiteSpace(); var token = mockMatchWhiteSpace.CallImplementation(stringTokenizer.Object); Assert.IsNull(token); }
public void ShouldCaptureCurrentTheLocation() { var stringTokenizer = new Mock <StringTokenizer>(string.Empty) { CallBase = true }; var mockMatchWhiteSpace = new MockMatchWhiteSpace(); mockMatchWhiteSpace.CallImplementation(stringTokenizer.Object); stringTokenizer.Verify(t => t.GetCurrentLocation(), Times.Once); }
public void ShouldStopConsumingWhiteSpaceAtANonWhiteSpaceCharacter() { var stringTokenizer = new Mock <StringTokenizer>(" 123") { CallBase = true }; var mockMatchWhiteSpace = new MockMatchWhiteSpace(); mockMatchWhiteSpace.CallImplementation(stringTokenizer.Object); stringTokenizer.Verify(t => t.Consume(), Times.Once); stringTokenizer.Verify(t => t.IsAtEnd(), Times.AtLeastOnce); Assert.AreEqual("1", stringTokenizer.Object.Current); }
public void ShouldStopConsumingWhiteSpaceAtTheEndOfTheTokenizer() { var stringTokenizer = new Mock <StringTokenizer>(" ") { CallBase = true }; var mockMatchWhiteSpace = new MockMatchWhiteSpace(); mockMatchWhiteSpace.CallImplementation(stringTokenizer.Object); stringTokenizer.Verify(t => t.Consume(), Times.Once); stringTokenizer.Verify(t => t.IsAtEnd(), Times.AtLeastOnce); Assert.IsTrue(stringTokenizer.Object.IsAtEnd()); }
public void ShouldCreateATokenFromCurrentTheLoction() { var tokenLocation = new Mock <ITokenLocation>(MockBehavior.Default); var stringTokenizer = new Mock <StringTokenizer>(" ") { CallBase = true }; stringTokenizer.Setup(t => t.GetCurrentLocation()).Returns(tokenLocation.Object); var mockMatchWhiteSpace = new MockMatchWhiteSpace(); mockMatchWhiteSpace.CallImplementation(stringTokenizer.Object); tokenLocation.Verify(l => l.CreateToken(It.IsAny <TokenType>(), It.IsAny <string>()), Times.Once); }