Example #1
0
        static void Main(string[] args)
        {
            const string incorrectNumber = "Incorrect number of arguments!", example = "Usage RemoveExtraBlanks.exe <inputFile> <outputFile>";

            if (args.Length != 2)
            {
                Console.WriteLine(incorrectNumber);
                Console.WriteLine(example);
                return;
            }

            string inputFile  = args[0];
            string outputFile = args[1];

            StringProcessor stringProcessor = new StringProcessor();

            using (StreamReader readerStream = new StreamReader(inputFile))
                using (StreamWriter writerStream = new StreamWriter(outputFile))
                {
                    while (!readerStream.EndOfStream)
                    {
                        string line = readerStream.ReadLine();
                        line = stringProcessor.RemoveExtraBlanks(line);
                        writerStream.WriteLine(line);
                    }
                }
        }
Example #2
0
        public void TestRemoveExtraBlanks()
        {
            StringProcessor stringProcessor = new StringProcessor();

            Assert.AreEqual("", stringProcessor.RemoveExtraBlanks("  "));
            Assert.AreEqual("hndk", stringProcessor.RemoveExtraBlanks(" hndk\t "));
            Assert.AreEqual("аоытвк", stringProcessor.RemoveExtraBlanks(" аоытвк \t"));
            Assert.AreEqual("оанаы оышыв", stringProcessor.RemoveExtraBlanks("оанаы оышыв"));
            Assert.AreEqual("оанаы оышыв", stringProcessor.RemoveExtraBlanks("оанаы  оышыв"));
            Assert.AreEqual("аонк\tjgh", stringProcessor.RemoveExtraBlanks("аонк\t  jgh "));
        }