private void AssertCurrent(Scanner scanner, Token expected) { Dump.WriteLine(expected.GetType().Name); Assert.NotNull(scanner.Current); Assert.True(expected.GetType().IsAssignableFrom(scanner.Current.GetType())); foreach (var property in expected.GetType().GetProperties()) { if (property.PropertyType != typeof(Mark) && property.CanRead) { var value = property.GetValue(scanner.Current, null); Dump.WriteLine("\t{0} = {1}", property.Name, value); Assert.Equal(property.GetValue(expected, null), value); } } }
private void AssertToken(Token expected, Token actual, int tokenNumber) { Dump.WriteLine(expected.GetType().Name); actual.Should().NotBeNull(); actual.GetType().Should().Be(expected.GetType(), "Token {0} is not of the expected type", tokenNumber); foreach (var property in expected.GetType().GetProperties()) { if (property.PropertyType != typeof(Mark) && property.CanRead) { var value = property.GetValue(actual, null); var expectedValue = property.GetValue(expected, null); Dump.WriteLine("\t{0} = {1}", property.Name, value); value.Should().Be(expectedValue, "Comparing property {0} in token {1}", property.Name, tokenNumber); } } }
private void AssertCurrent(Scanner scanner, Token expected) { Console.WriteLine(expected.GetType().Name); Assert.IsNotNull(scanner.Current, "The current token is null."); Assert.IsTrue(expected.GetType().IsAssignableFrom(scanner.Current.GetType()), "The token is not of the expected type."); foreach (var property in expected.GetType().GetProperties()) { if(property.PropertyType != typeof(Mark) && property.CanRead) { object value = property.GetValue(scanner.Current, null); Console.WriteLine("\t{0} = {1}", property.Name, value); Assert.AreEqual(property.GetValue(expected, null), value, string.Format("The property '{0}' is incorrect.", property.Name)); } } }