public void ReturnsAndCommentsValidDirectives() { // Given IPreprocessor preprocessor = new TestPreprocessor(); DirectiveParser directiveParser = new DirectiveParser(preprocessor); string configScript = @"#valid a b c #invalid a b c #validx y z A= =B #valid x y z C"; // When directiveParser.Parse(configScript); // Then Assert.AreEqual(@"//#valid a b c #invalid a b c #validx y z A= =B //#valid x y z C", directiveParser.Code); CollectionAssert.AreEqual(new[] { Tuple.Create((int?)1, "valid", "a b c"), Tuple.Create((int?)6, "valid", "x y z") }, directiveParser.DirectiveValues.Select(x => Tuple.Create(x.Line, x.Name, x.Value))); }
public void ReturnsAndCommentsValidDirectives() { // Given IPreprocessor preprocessor = new TestPreprocessor(); DirectiveParser directiveParser = new DirectiveParser(preprocessor); const string configScript = @"#valid a b c #invalid a b c #validx y z A= =B #valid x y z C"; // When directiveParser.Parse(configScript); // Then directiveParser.Code.ShouldBe( @"//#valid a b c #invalid a b c #validx y z A= =B //#valid x y z C", StringCompareShould.IgnoreLineEndings); directiveParser.DirectiveValues .Select(x => Tuple.Create(x.Line, x.Name, x.Value)) .ShouldBe( new[] { Tuple.Create((int?)1, "valid", "a b c"), Tuple.Create((int?)6, "valid", "x y z") }); }
public void ReturnsValidDirectivesWithDeclarations() { // Given IPreprocessor preprocessor = new TestPreprocessor(); string configScript = @"#valid a A= =B #invalid b C --- E- #valid c -F"; // When ConfigParserResult result = ConfigParser.Parse(configScript, preprocessor); // Then Assert.AreEqual(@"#line 1 //#valid a A= =B #invalid b C", result.Declarations); Assert.AreEqual(@"#line 7 E- //#valid c -F", result.Body); CollectionAssert.AreEqual(new[] { Tuple.Create((int?)1, "valid", "a"), Tuple.Create((int?)8, "valid", "c") }, result.DirectiveValues.Select(x => Tuple.Create(x.Line, x.Name, x.Value))); }
public void ReturnsDeclarationsWithDelimiterWithLeadingSpaces() { // Given IPreprocessor preprocessor = new TestPreprocessor(); string configScript = @"A= =B === =C D --- -E F"; // When ConfigParserResult result = ConfigParser.Parse(configScript, preprocessor); // Then Assert.IsNull(result.Declarations); Assert.AreEqual(@"#line 1 A= =B === =C D --- -E F", result.Body); }
public void ReturnsValidDirectives() { // Given IPreprocessor preprocessor = new TestPreprocessor(); string configScript = @"#valid a b c #invalid a b c #validx y z A= =B #valid x y z C"; // When ConfigParserResult result = ConfigParser.Parse(configScript, preprocessor); // Then Assert.IsNull(result.Declarations); Assert.AreEqual(@"#line 1 //#valid a b c #invalid a b c #validx y z A= =B //#valid x y z C", result.Body); CollectionAssert.AreEqual(new [] { Tuple.Create((int?)1, "valid", "a b c"), Tuple.Create((int?)6, "valid", "x y z") }, result.DirectiveValues.Select(x => Tuple.Create(x.Line, x.Name, x.Value))); }
public void ReturnsDeclarationsWithDelimiterWithExtraLines() { // Given IPreprocessor preprocessor = new TestPreprocessor(); string configScript = @"A- =B -C D --- E- -F"; // When ConfigParserResult result = ConfigParser.Parse(configScript, preprocessor); // Then Assert.AreEqual(@"#line 1 A- =B -C D ", result.Declarations); Assert.AreEqual(@"#line 7 E- -F", result.Body); }
public void DoesNotProcessDirectivesWithSpaceAfterHash() { // Given IPreprocessor preprocessor = new TestPreprocessor(); DirectiveParser directiveParser = new DirectiveParser(preprocessor); string configScript = @"# valid a b c A"; // When directiveParser.Parse(configScript); // Then Assert.AreEqual(@"# valid a b c A", directiveParser.Code); CollectionAssert.IsEmpty(directiveParser.DirectiveValues); }
public void DoesNotProcessDirectivesWithSpaceAfterHash() { // Given IPreprocessor preprocessor = new TestPreprocessor(); DirectiveParser directiveParser = new DirectiveParser(preprocessor); string configScript = @"# valid a b c A"; // When directiveParser.Parse(configScript); // Then directiveParser.Code.ShouldBe(@"# valid a b c A", StringCompareShould.IgnoreLineEndings); directiveParser.DirectiveValues.ShouldBeEmpty(); }
public void DoesNotProcessDirectivesWithSpaceAfterHash() { // Given IPreprocessor preprocessor = new TestPreprocessor(); string configScript = @"# valid a b c A"; // When ConfigParserResult result = ConfigParser.Parse(configScript, preprocessor); // Then Assert.IsNull(result.Declarations); Assert.AreEqual(@"#line 1 # valid a b c A", result.Body); CollectionAssert.IsEmpty(result.DirectiveValues); }
public void ReturnsSameCode() { // Given IPreprocessor preprocessor = new TestPreprocessor(); DirectiveParser directiveParser = new DirectiveParser(preprocessor); string configScript = @"A B C"; // When directiveParser.Parse(configScript); // Then CollectionAssert.IsEmpty(directiveParser.DirectiveValues); Assert.AreEqual(@"A B C", directiveParser.Code); }
public void ReturnsConfigWithoutDelimiter() { // Given IPreprocessor preprocessor = new TestPreprocessor(); string configScript = @"A= =B C"; // When ConfigParserResult result = ConfigParser.Parse(configScript, preprocessor); // Then Assert.IsNull(result.Declarations); Assert.AreEqual(@"#line 1 A= =B C", result.Body); }
public void ReturnsSameCode() { // Given IPreprocessor preprocessor = new TestPreprocessor(); DirectiveParser directiveParser = new DirectiveParser(preprocessor); string configScript = @"A B C"; // When directiveParser.Parse(configScript); // Then directiveParser.DirectiveValues.ShouldBeEmpty(); directiveParser.Code.ShouldBe(@"A B C", StringCompareShould.IgnoreLineEndings); }
public void ReturnsDeclarations() { // Given IPreprocessor preprocessor = new TestPreprocessor(); string configScript = @"A= =B C --- E- -F"; // When ConfigParserResult result = ConfigParser.Parse(configScript, preprocessor); // Then Assert.AreEqual(@"#line 1 A= =B C", result.Declarations); Assert.AreEqual(@"#line 5 E- -F", result.Body); }