public async Task Should_ReturnEmptyResult_When_InputIsEmpty()
        {
            var parser = new OperationFilesParser(null);

            var result = await parser.ParseOperationsFiles(new string[0]);

            Assert.AreEqual(0, result.LoadedOperations.Count);
            Assert.AreEqual(0, result.PairableOperations.Count());
            Assert.AreEqual(0, result.ParsingResults.Count);
        }
        public async Task Should_ReturnIsErrorResult_When_NoParsersAreDefined()
        {
            var parser = new OperationFilesParser(GetParsersProvider(new List <Type>()));

            var result = await parser.ParseOperationsFiles(new string[] { windows1250FilePath });

            Assert.AreEqual(0, result.LoadedOperations.Count);
            Assert.AreEqual(0, result.PairableOperations.Count());
            Assert.AreEqual(1, result.ParsingResults.Count);
            var fileImportResult = result.ParsingResults[0];

            Assert.IsTrue(fileImportResult.IsError);
            Assert.IsNull(fileImportResult.Exception);
        }
        public async Task Should_ReturnIsErrorWithExceptionResult_When_FileDoesNotExist()
        {
            var parser = new OperationFilesParser(GetParsersProvider(new List <Type>()));

            var result = await parser.ParseOperationsFiles(new string[] { "not_existing_file.txt" });

            Assert.AreEqual(0, result.LoadedOperations.Count);
            Assert.AreEqual(0, result.PairableOperations.Count());
            Assert.AreEqual(1, result.ParsingResults.Count);
            var fileImportResult = result.ParsingResults[0];

            Assert.IsTrue(fileImportResult.IsError);
            Assert.IsNotNull(fileImportResult.Exception);
        }
        public async Task Should_Read1250FileCorrectly()
        {
            string fileContents = File.ReadAllText(windows1250FilePath, CodePagesEncodingProvider.Instance.GetEncoding(1250));

            var parser = new OperationFilesParser(GetParsersProvider(new List <Type>()
            {
                typeof(FakeAlwaysCanParseWindows1250Parser)
            }));

            var result = await parser.ParseOperationsFiles(new string[] { windows1250FilePath });

            Assert.AreEqual(1, result.LoadedOperations.Count);
            Assert.AreEqual(0, result.PairableOperations.Count());
            Assert.AreEqual(1, result.ParsingResults.Count);
            var fileImportResult = result.ParsingResults[0];

            Assert.IsFalse(fileImportResult.IsError);
            Assert.AreEqual(fileContents, result.LoadedOperations[0].Description);
        }
        public async Task Should_ReadUft8FileCorrectly()
        {
            string fileContents = File.ReadAllText(utf8FilePath, Encoding.UTF8);

            var parser = new OperationFilesParser(GetParsersProvider(new List <Type>()
            {
                typeof(FakeAlwaysCanParseUtf8Parser)
            }));

            var result = await parser.ParseOperationsFiles(new string[] { utf8FilePath });

            Assert.AreEqual(1, result.LoadedOperations.Count);
            Assert.AreEqual(0, result.PairableOperations.Count());
            Assert.AreEqual(1, result.ParsingResults.Count);
            var fileImportResult = result.ParsingResults[0];

            Assert.IsFalse(fileImportResult.IsError);
            Assert.AreEqual(fileContents, result.LoadedOperations[0].Description);
        }