示例#1
0
        public void BadFilePathFile()
        {
            ParseT9 parseT9 = new ParseT9();

            bool res = parseT9.ProcessFileAsync("").Result;

            Assert.That(res, Is.EqualTo(false));
        }
示例#2
0
        public void BadFormatFile()
        {
            ParseT9 parseT9 = new ParseT9();

            string filePath = Test_StaticData.CreateAndFillFile("abc");

            bool res = parseT9.ProcessFileAsync(filePath).Result;

            Assert.That(res, Is.EqualTo(false));
        }
示例#3
0
        public void BigFile()
        {
            string filePath    = Test_StaticData.CreateAndFillFile(Test_StaticData.BigFileContent);
            string outFilePath = Test_StaticData.CreateAndFillFile();

            ParseT9 parseT9 = new ParseT9(filePath, outFilePath);
            bool    res     = parseT9.ProcessFileAsync().Result;

            //Сравниваем с эталонным хэшем файла - означает что конвертировали правильно
            string resultHash = Test_StaticData.GetFileHash(outFilePath);

            File.Delete(filePath);
            File.Delete(outFilePath);

            Assert.That(resultHash, Is.EqualTo(Test_StaticData.BigFileHash));
        }
示例#4
0
        public void SmallFile()
        {
            ParseT9 parseT9 = new ParseT9();

            string fileContent = "2" + '\n' + "abc" + '\n' + "";

            string filePath = Test_StaticData.CreateAndFillFile(fileContent);

            bool res = parseT9.ProcessFileAsync(filePath).Result;

            string retStr;

            parseT9.ResultConcurrentDictionary.TryGetValue(1, out retStr);

            File.Delete(filePath);

            Assert.That(retStr, Is.EqualTo(StaticData.StartString + "1" + StaticData.MiddleString + "2 22 222"));
        }
示例#5
0
        public void SmallFile()
        {
            string fileContent = "2" + '\n' + "abc" + '\n' + "";
            string filePath    = Test_StaticData.CreateAndFillFile(fileContent);

            ParseT9 parseT9 = new ParseT9()
            {
                NeedSaveToFile = false
            };
            bool res = parseT9.ProcessFileAsync(filePath).Result;

            parseT9.OutFilePath = Path.GetTempFileName();
            parseT9.SaveToFile();

            Assert.That(File.Exists(parseT9.OutFilePath), Is.EqualTo(true));

            File.Delete(filePath);
            File.Delete(parseT9.OutFilePath);
        }
示例#6
0
        public void BigFile()
        {
            string fileContent = Test_StaticData.BigFileContent;
            string filePath    = Test_StaticData.CreateAndFillFile(fileContent);

            ParseT9 parseT9 = new ParseT9()
            {
                NeedSaveToFile = false
            };
            bool res = parseT9.ProcessFileAsync(filePath).Result;

            parseT9.OutFilePath = Path.GetTempFileName();
            parseT9.SaveToFile();

            string resultHash = Test_StaticData.GetFileHash(parseT9.OutFilePath);

            File.Delete(filePath);
            File.Delete(parseT9.OutFilePath);

            Assert.That(resultHash, Is.EqualTo(Test_StaticData.BigFileHash));
        }
示例#7
0
        private async void bStartProcess_Click(object sender, EventArgs e)
        {
            if (File.Exists(tbFilePath.Text))
            {
                ParseT9 parseT9 = new ParseT9(tbFilePath.Text, tbFilePath2.Text);

                bool res = await parseT9.ProcessFileAsync();

                if (res)
                {
                    MessageBox.Show("Готово");

                    Process.Start("notepad.exe", parseT9.OutFilePath);
                }
                else
                {
                    MessageBox.Show("Что-то не так");
                }
            }
            else
            {
                MessageBox.Show("Файл не найден");
            }
        }