public void CreateInstance_TokensNotEmpty_IsNotAtEnd() { // Arrange // Act var target = new FragmentTokenSource(new[] { FragmentTokenSourceTests.CreateFragmentToken("E") }); // Assert Assert.IsFalse(target.IsEnd); }
public void CreateInstance_TokensNotEmpty_TokenThrows() { // Arrange var tokens = new[] { FragmentTokenSourceTests.CreateFragmentToken("A"), FragmentTokenSourceTests.CreateFragmentToken("B") }; var target = new FragmentTokenSource(tokens); // Act var t = target.Token; // Assert }
public void MoveNext_FirstCall_IsEndIsFalse() { // Arrange var tokens = new[] { FragmentTokenSourceTests.CreateFragmentToken("A"), FragmentTokenSourceTests.CreateFragmentToken("B") }; var target = new FragmentTokenSource(tokens); // Act target.MoveNext(); // Assert Assert.IsFalse(target.IsEnd); }
public void MoveNext_FirstCall_TokenIsFirstToken() { // Arrange var tokens = new[] { FragmentTokenSourceTests.CreateFragmentToken("A"), FragmentTokenSourceTests.CreateFragmentToken("B") }; var target = new FragmentTokenSource(tokens); // Act target.MoveNext(); // Assert Assert.AreEqual(tokens[0], target.Token); }
public void CreateInstance_LookAhead_ContainsAllTokens() { // Arrange var tokens = new[] { FragmentTokenSourceTests.CreateFragmentToken("A"), FragmentTokenSourceTests.CreateFragmentToken("B") }; var target = new FragmentTokenSource(tokens); // Act var lookAhead = target.LookAhead.ToArray(); // Assert Assert.IsTrue(tokens.SequenceEqual(lookAhead)); }
public void MoveNext_FirstCall_LookAheadSkipsFirstToken() { // Arrange var tokens = new[] { FragmentTokenSourceTests.CreateFragmentToken("A"), FragmentTokenSourceTests.CreateFragmentToken("B") }; var target = new FragmentTokenSource(tokens); // Act target.MoveNext(); var lookAhead = target.LookAhead.ToArray(); // Assert Assert.IsTrue(tokens.Skip(1).SequenceEqual(lookAhead)); }
public void FragmentTokenSource_IntegrationTest_BehavesAsExpected() { // Arrange var tokens = new[] { FragmentTokenSourceTests.CreateFragmentToken("A"), FragmentTokenSourceTests.CreateFragmentToken("B"), FragmentTokenSourceTests.CreateFragmentToken("C"), FragmentTokenSourceTests.CreateFragmentToken("D") }; var target = new FragmentTokenSource(tokens); // Integration Assert.IsFalse(target.IsEnd); Assert.AreEqual(tokens.Length, target.LookAhead.Count()); Assert.IsTrue(target.MoveNext()); Assert.IsFalse(target.IsEnd); Assert.AreEqual(tokens[0], target.Token); Assert.AreEqual(tokens.Length - 1, target.LookAhead.Count()); Assert.IsTrue(target.MoveNext()); Assert.IsFalse(target.IsEnd); Assert.AreEqual(tokens[1], target.Token); Assert.AreEqual(tokens.Length - 2, target.LookAhead.Count()); Assert.IsTrue(target.MoveNext()); Assert.IsFalse(target.IsEnd); Assert.AreEqual(tokens[2], target.Token); Assert.AreEqual(tokens.Length - 3, target.LookAhead.Count()); Assert.IsTrue(target.MoveNext()); Assert.IsFalse(target.IsEnd); Assert.AreEqual(tokens[3], target.Token); Assert.AreEqual(tokens.Length - 4, target.LookAhead.Count()); Assert.IsFalse(target.MoveNext()); Assert.IsTrue(target.IsEnd); }