public void WarningListAddEmpty() { var messageList = new RowErrorCollection(10); Assert.AreEqual(0, messageList.CountRows); try { // ReSharper disable once AssignNullToNotNullAttribute messageList.Add(null, new WarningEventArgs(1, 2, null, 0, 0, null)); Assert.Fail("Exception not thrown"); } catch (ArgumentException) { } try { messageList.Add(null, new WarningEventArgs(1, 2, string.Empty, 0, 0, null)); Assert.Fail("Exception not thrown"); } catch (ArgumentException) { } }
public void WarningListDisplay2() { var messageList = new RowErrorCollection(); messageList.Add(null, new WarningEventArgs(1, 1, "Text1", 0, 1, null)); messageList.Add(null, new WarningEventArgs(1, 2, "Text2", 0, 2, null)); Assert.IsTrue( "Text1" + ErrorInformation.cSeparator + "Text2" == messageList.Display || "Text2" + ErrorInformation.cSeparator + "Text1" == messageList.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 DisplayByRecordNumber() { var coll = new RowErrorCollection(5); coll.Add(this, new WarningEventArgs(425, 1, "Message1", 100, 100, "ColName")); Assert.IsTrue(coll.DisplayByRecordNumber.Contains("Row 425")); }
public void TryGetValue() { var coll = new RowErrorCollection(5); coll.Add(this, new WarningEventArgs(1, 1, "Message1", 100, 100, "ColName")); Assert.IsTrue(coll.TryGetValue(1, out var val)); }
public void Clear() { var coll = new RowErrorCollection(5); coll.Add(this, new WarningEventArgs(1, 1, "Message1", 100, 100, "ColName")); Assert.AreEqual(1, coll.CountRows); coll.Clear(); Assert.AreEqual(0, coll.CountRows); }
public void WarningListAddAndClear() { var messageList = new RowErrorCollection(); Assert.AreEqual(0, messageList.CountRows); messageList.Add(null, new WarningEventArgs(1, 2, "Line1", 0, 0, null)); Assert.AreEqual(1, messageList.CountRows); messageList.Clear(); Assert.AreEqual(0, messageList.CountRows); }
public void WarningListAddEmpty() { var messageList = new RowErrorCollection(); Assert.AreEqual(0, messageList.CountRows); try { messageList.Add(null, new WarningEventArgs(1, 2, null, 0, 0, null)); Assert.Fail("Exception not thrown"); } catch (System.ArgumentException) { } try { messageList.Add(null, new WarningEventArgs(1, 2, string.Empty, 0, 0, null)); Assert.Fail("Exception not thrown"); } catch (System.ArgumentException) { } }
public async Task HandleIgnoredColumns() { var coll = new RowErrorCollection(5); using (var reader = new CsvFileReader(UnitTestInitializeCsv.GetTestPath("AllFormats.txt"), Encoding.UTF8.CodePage, 0, true, new IColumn[] { new ImmutableColumn("DateTime", new ImmutableValueFormat(DataType.DateTime), 0, true, "", true), new ImmutableColumn("Integer", new ImmutableValueFormat(DataType.Integer), 0, true, "", true), })) { await reader.OpenAsync(CancellationToken.None); coll.HandleIgnoredColumns(reader); // An error i an ignored column is not stored coll.Add(this, new WarningEventArgs(1, 0, "Message1", 100, 100, "ColName")); Assert.AreEqual(0, coll.CountRows); } }
public void Add() { var coll = new RowErrorCollection(5); coll.Add(this, new WarningEventArgs(1, 1, "Message1", 100, 100, "ColName")); Assert.AreEqual(1, coll.CountRows); coll.Add(this, new WarningEventArgs(2, 1, "Message1", 101, 101, "ColName")); Assert.AreEqual(2, coll.CountRows); coll.Add(this, new WarningEventArgs(3, 1, "Message1", 102, 102, "ColName")); Assert.AreEqual(3, coll.CountRows); coll.Add(this, new WarningEventArgs(4, 1, "Message1", 103, 103, "ColName")); Assert.AreEqual(4, coll.CountRows); coll.Add(this, new WarningEventArgs(5, 1, "Message1", 104, 104, "ColName")); Assert.AreEqual(5, coll.CountRows); /// This should be cut off coll.Add(this, new WarningEventArgs(6, 1, "Message1", 105, 105, "ColName")); Assert.AreEqual(5, coll.CountRows); }