Create() public method

public Create ( ) : IFileParser
return IFileParser
Beispiel #1
0
        public void ParseFile_GivenFilePath_UTF8Encoding_AndReplaceCapitalParseMode()
        {
            string filePath = "test.txt";
            StreamWriter sw = new StreamWriter(File.Create(filePath));
            foreach (string s in testStrings)
                sw.WriteLine(s);
            sw.Close();

            FileParserFactory fileParserBuilder = new FileParserFactory(filePath, Encoding.UTF8, ParseStrategy.ReplaceCapitalLetters());
            IFileParser fileParser = fileParserBuilder.Create();
            StreamReader sr = fileParser.ParseFile();

            int i = 0;
            while (!sr.EndOfStream)
            {
                Assert.IsTrue(sr.ReadLine() == lowercaseResultStrings[i]);
                i++;
            }

            sr.Close();
        }
Beispiel #2
0
        public void ParseFile_GivenFilePath_UTF8Encoding_AndLeaveUnchangedParseMode()
        {
            string filePath = "test.txt";
            StreamWriter sw = new StreamWriter(File.Create(filePath));
            foreach (string s in testStrings)
                sw.WriteLine(s);
            sw.Close();

            FileParserFactory fileParserBuilder = new FileParserFactory(filePath, Encoding.UTF8);
            IFileParser fileParser = fileParserBuilder.Create();
            StreamReader sr = fileParser.ParseFile();

            int i = 0;
            while(!sr.EndOfStream)
            {
                Assert.IsTrue(sr.ReadLine() == defaultResultStrings[i]);
                i++;
            }

            sr.Close();
        }
Beispiel #3
0
        public void ParseFile_GivenHtmlFilePath_UTF8Encoding_AndLeaveUnchangedParseStrategy()
        {
            string filePath = "test.html";
            StreamWriter sw = new StreamWriter(File.Create(filePath));
            sw.Write(htmlTest);
            sw.Close();

            FileParserFactory fileParserBuilder = new FileParserFactory(filePath, Encoding.UTF8);
            IFileParser fileParser = fileParserBuilder.Create();
            StreamReader sr = fileParser.ParseFile();

            Assert.IsTrue(sr.ReadToEnd() == htmlTestResult);

            sr.Close();
        }
Beispiel #4
0
        private StreamReader GetParsedFileStream(IParseStrategy parseStrategy)
        {
            var fileParserFactory = new FileParserFactory(_searchFile, parseStrategy);

            var fileParser = fileParserFactory.Create();
            var streamReader = fileParser.ParseFile();

            return streamReader;
        }