public void Will_parse_the_source_code() { StubLanguageParser stubLanguageParser = new StubLanguageParser(); CodeColorizer codeColorizer = new CodeColorizer(stubLanguageParser); const string sourceCode = "fnord"; StubLanguage stubLanguage = new StubLanguage(); codeColorizer.Colorize(sourceCode, stubLanguage, new StubFormatter(), new StubStyleSheet(), new StubTextWriter()); Assert.Equal(sourceCode, stubLanguageParser.Parse__sourceCode); Assert.Equal(stubLanguage, stubLanguageParser.Parse__language); }
public void Will_write_the_header() { StubLanguageParser stubLanguageParser = new StubLanguageParser(); CodeColorizer codeColorizer = new CodeColorizer(stubLanguageParser); const string sourceCode = "fnord"; StubFormatter stubFormatter = new StubFormatter(); StubStyleSheet stubStyleSheet = new StubStyleSheet(); StubTextWriter stubTextWriter = new StubTextWriter(); codeColorizer.Colorize(sourceCode, new StubLanguage(), stubFormatter, stubStyleSheet, stubTextWriter); Assert.Equal(stubTextWriter, stubFormatter.WriteHeader__textWriter); Assert.Equal(stubStyleSheet, stubFormatter.WriteHeader__styleSheet); }
public void Will_write_the_parsed_source_code() { StubLanguageParser languageParser = new StubLanguageParser(); languageParser.Parse__do = (sourceCodeToParse, language, parsedSourceCodeHandler) => { parsedSourceCodeHandler("parsedSourceCode1", new List<Scope>()); parsedSourceCodeHandler("parsedSourceCode2", new List<Scope>()); }; CodeColorizer codeColorizer = new CodeColorizer(languageParser); const string sourceCode = "fnord"; StubFormatter formatter = new StubFormatter(); codeColorizer.Colorize(sourceCode, new StubLanguage(), formatter, new StubStyleSheet(), new StubTextWriter()); Assert.Equal("parsedSourceCode2", formatter.Write__parsedSourceCode.Pop()); Assert.Equal("parsedSourceCode1", formatter.Write__parsedSourceCode.Pop()); }
public void Will_write_the_footer() { StubLanguageParser languageParser = new StubLanguageParser(); CodeColorizer codeColorizer = new CodeColorizer(languageParser); const string sourceCode = "fnord"; StubFormatter formatter = new StubFormatter(); StubStyleSheet styleSheet = new StubStyleSheet(); StubTextWriter writer = new StubTextWriter(); codeColorizer.Colorize(sourceCode, new StubLanguage(), formatter, styleSheet, writer); Assert.Equal(writer, formatter.WriteFooter__writer); Assert.Equal(styleSheet, formatter.WriteFooter__styleSheet); }