public async Task ColumnErrorDictionaryTest1Async()
        {
            var setting = new CsvFile
            {
                FileName       = UnitTestInitializeCsv.GetTestPath("Sessions.txt"),
                HasFieldHeader = true,
                ByteOrderMark  = true,
                FileFormat     = { FieldDelimiter = "\t" }
            };

            setting.ColumnCollection.AddIfNew(new Column("Start Date")
            {
                Ignore = true
            });

            using (var processDisplay = new CustomProcessDisplay(UnitTestInitializeCsv.Token))
                using (var reader = new CsvFileReader(setting, processDisplay))
                {
                    await reader.OpenAsync(processDisplay.CancellationToken);

                    var test1 = new ColumnErrorDictionary(reader);
                    Assert.IsNotNull(test1);

                    // Message in ignored column
                    reader.HandleWarning(0, "Msg1");
                    reader.HandleError(1, "Msg2");

                    Assert.AreEqual("Msg2", test1.Display);
                }
        }
        public void AddTest()
        {
            var test1 = new ColumnErrorDictionary();

            Assert.IsNotNull(test1);
            test1.Add(0, "Message");
            Assert.AreEqual("Message", test1.Display);
            test1.Add(0, "Another Message");
            Assert.AreEqual("Message" + ErrorInformation.cSeparator + "Another Message", test1.Display);
        }
        public void WarningListCombineWarning()
        {
            var messageList = new RowErrorCollection(10);

            messageList.Add(null, new WarningEventArgs(1, 1, "Text1", 0, 0, null));
            messageList.Add(null, new WarningEventArgs(1, 1, "Text2", 0, 1, null));
            Assert.AreEqual(1, messageList.CountRows);
            Assert.IsTrue(
                "Text1" + ErrorInformation.cSeparator + "Text2" == messageList.Display ||
                "Text2" + ErrorInformation.cSeparator + "Text1" == messageList.Display);
            _ = new ColumnErrorDictionary();
            messageList.TryGetValue(1, out var ce);
            Assert.AreEqual(1, ce.Count);
            Assert.AreEqual(messageList.Display, ce.Display);
        }
        public void ReadErrorInformationTestSetErrorInformation()
        {
            var columnErrors = new ColumnErrorDictionary();

            var colNames = new List <string>();

            foreach (DataColumn col in m_DataTable.Columns)
            {
                colNames.Add(col.ColumnName);
            }

            Assert.IsTrue(string.IsNullOrEmpty(ErrorInformation.ReadErrorInformation(columnErrors, colNames)));

            columnErrors.Add(-1, "Error on Row");
            columnErrors.Add(0, "Error on Column".AddWarningId());
            columnErrors.Add(1, "Error on ColumnA");
            columnErrors.Add(1, "Another Error on Column");

            columnErrors.Add(2, "Warning on ColumnB".AddWarningId());

            columnErrors.Add(3, "Warning on Fld4".AddWarningId());
            columnErrors.Add(3, "Error on Fld4");

            var errorInfo = ErrorInformation.ReadErrorInformation(columnErrors, colNames);

            Assert.IsNotNull(errorInfo);

            var row = m_DataTable.NewRow();

            row.SetErrorInformation(errorInfo);
            Assert.AreEqual("Error on Row", row.RowError);
            Assert.AreEqual("Error on Column", row.GetColumnError(0).WithoutWarningId());
            Assert.AreEqual("Error on ColumnA\nAnother Error on Column", row.GetColumnError(1));
            Assert.AreEqual("Warning on ColumnB", row.GetColumnError(2).WithoutWarningId());

            var res = errorInfo.GetErrorsAndWarings();

            Assert.AreEqual(4, res.Item1.Count(x => x == ErrorInformation.cSeparator) + 1);
            Assert.AreEqual(3, res.Item2.Count(x => x == ErrorInformation.cSeparator) + 1);
        }