summaryrefslogtreecommitdiff
path: root/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter
diff options
context:
space:
mode:
Diffstat (limited to 'ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter')
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanFalseValuesAttributeTests.cs110
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanFalseValuesMapTests.cs125
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanTrueValuesAttributeTests.cs110
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanTrueValuesMapTests.cs125
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/ConstantAttributeTests.cs109
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/ConstantMapTests.cs193
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/CultureInfoAttributeTests.cs119
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/CultureInfoMapTests.cs160
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DateTimeStylesAttributeTests.cs109
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DateTimeStylesMapTests.cs152
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DefaultAttributeTests.cs108
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DefaultMapTests.cs152
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/EnumIgnoreCaseTests.cs113
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/FormatAttributeTests.cs111
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/FormatMapTests.cs156
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/HeaderPrefixAttributeTests.cs111
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/HeaderPrefixMapTests.cs6
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IgnoreAttributeTests.cs106
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IgnoreMapTests.cs150
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IndexAttributeTests.cs106
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IndexMapTests.cs149
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameAttributeTests.cs85
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameIndexAttributeTests.cs85
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameIndexMapTests.cs126
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameMapTests.cs126
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NullValuesAttributeTests.cs107
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NullValuesMapTests.cs122
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NumberStylesAttributeTests.cs108
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NumberStylesMapTests.cs151
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/OptionalAttributeTests.cs106
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/OptionalMapTests.cs150
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/TypeConverterAttributeTests.cs115
-rw-r--r--ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/TypeConverterMapTests.cs158
33 files changed, 4019 insertions, 0 deletions
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanFalseValuesAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanFalseValuesAttributeTests.cs
new file mode 100644
index 0000000..d05b601
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanFalseValuesAttributeTests.cs
@@ -0,0 +1,110 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class BooleanFalseValuesAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithBooleanFalseValuesAttribute_CreatesParameterMaps()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture);
+ var context = new CsvContext(config);
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Empty(map.ParameterMaps[0].Data.TypeConverterOptions.BooleanTrueValues);
+ Assert.Empty(map.ParameterMaps[0].Data.TypeConverterOptions.BooleanFalseValues);
+ Assert.Empty(map.ParameterMaps[1].Data.TypeConverterOptions.BooleanTrueValues);
+ Assert.Single(map.ParameterMaps[1].Data.TypeConverterOptions.BooleanFalseValues);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.TypeConverterOptions.BooleanFalseValues[0]);
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanFalseValuesAttribute_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "boolean" },
+ { "1", "Bar" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.False(records[0].Boolean);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanFalseValuesAttribute_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "Bar" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.False(records[0].Boolean);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithBooleanFalseValuesAttribute_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, false),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Boolean\r\n");
+ expected.Append("1,False\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public bool Boolean { get; private set; }
+
+ public Foo(int id, [BooleanFalseValues("Bar")] bool boolean)
+ {
+ Id = id;
+ Boolean = boolean;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanFalseValuesMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanFalseValuesMapTests.cs
new file mode 100644
index 0000000..c477a17
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanFalseValuesMapTests.cs
@@ -0,0 +1,125 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class BooleanFalseValuesMapTests
+ {
+ [Fact]
+ public void AutoMap_WithBooleanFalseValuesAttribute_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("boolean").TypeConverterOption.BooleanValues(false, true, "Bar");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Empty(map.ParameterMaps[0].Data.TypeConverterOptions.BooleanTrueValues);
+ Assert.Empty(map.ParameterMaps[0].Data.TypeConverterOptions.BooleanFalseValues);
+ Assert.Empty(map.ParameterMaps[1].Data.TypeConverterOptions.BooleanTrueValues);
+ Assert.Single(map.ParameterMaps[1].Data.TypeConverterOptions.BooleanFalseValues);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.TypeConverterOptions.BooleanFalseValues[0]);
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanFalseValuesAttribute_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "boolean" },
+ { "1", "Bar" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.False(records[0].Boolean);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanFalseValuesAttribute_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "Bar" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.False(records[0].Boolean);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithBooleanFalseValuesAttribute_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, false),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Boolean\r\n");
+ expected.Append("1,False\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public bool Boolean { get; private set; }
+
+ public Foo(int id, bool boolean)
+ {
+ Id = id;
+ Boolean = boolean;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Boolean);
+ Parameter("id");
+ Parameter("boolean").TypeConverterOption.BooleanValues(false, true, "Bar");
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanTrueValuesAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanTrueValuesAttributeTests.cs
new file mode 100644
index 0000000..4149e9d
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanTrueValuesAttributeTests.cs
@@ -0,0 +1,110 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class BooleanTrueValuesAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithBooleanTrueValuesAttribute_CreatesParameterMaps()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture);
+ var context = new CsvContext(config);
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Empty(map.ParameterMaps[0].Data.TypeConverterOptions.BooleanTrueValues);
+ Assert.Empty(map.ParameterMaps[0].Data.TypeConverterOptions.BooleanFalseValues);
+ Assert.Single(map.ParameterMaps[1].Data.TypeConverterOptions.BooleanTrueValues);
+ Assert.Empty(map.ParameterMaps[1].Data.TypeConverterOptions.BooleanFalseValues);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.TypeConverterOptions.BooleanTrueValues[0]);
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanTrueValuesAttribute_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "boolean" },
+ { "1", "Bar" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.True(records[0].Boolean);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanTrueValuesAttribute_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "Bar" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.True(records[0].Boolean);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithBooleanTrueValuesAttribute_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, true),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Boolean\r\n");
+ expected.Append("1,True\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public bool Boolean { get; private set; }
+
+ public Foo(int id, [BooleanTrueValues("Bar")]bool boolean)
+ {
+ Id = id;
+ Boolean = boolean;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanTrueValuesMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanTrueValuesMapTests.cs
new file mode 100644
index 0000000..318b439
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/BooleanTrueValuesMapTests.cs
@@ -0,0 +1,125 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class BooleanTrueValuesMapTests
+ {
+ [Fact]
+ public void AutoMap_WithBooleanFalseValuesAttribute_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("boolean").TypeConverterOption.BooleanValues(true, true, "Bar");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Empty(map.ParameterMaps[0].Data.TypeConverterOptions.BooleanTrueValues);
+ Assert.Empty(map.ParameterMaps[0].Data.TypeConverterOptions.BooleanFalseValues);
+ Assert.Single(map.ParameterMaps[1].Data.TypeConverterOptions.BooleanTrueValues);
+ Assert.Empty(map.ParameterMaps[1].Data.TypeConverterOptions.BooleanFalseValues);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.TypeConverterOptions.BooleanTrueValues[0]);
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanFalseValuesAttribute_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "boolean" },
+ { "1", "Bar" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.True(records[0].Boolean);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanFalseValuesAttribute_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "Bar" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.True(records[0].Boolean);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithBooleanFalseValuesAttribute_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, true),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Boolean\r\n");
+ expected.Append("1,True\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public bool Boolean { get; private set; }
+
+ public Foo(int id, bool boolean)
+ {
+ Id = id;
+ Boolean = boolean;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Boolean);
+ Parameter("id");
+ Parameter("boolean").TypeConverterOption.BooleanValues(true, true, "Bar");
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/ConstantAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/ConstantAttributeTests.cs
new file mode 100644
index 0000000..bf42bdc
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/ConstantAttributeTests.cs
@@ -0,0 +1,109 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class ConstantAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithConstantAttributes_ConfiguresParameterMaps()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture);
+ var context = new CsvContext(config);
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsConstantSet);
+ Assert.Null(map.ParameterMaps[0].Data.Constant);
+ Assert.True(map.ParameterMaps[1].Data.IsConstantSet);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.Constant);
+ }
+
+ [Fact]
+ public void GetRecords_WithConstantAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "name" },
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithConstantAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithConstantAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, null),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, [Constant("Bar")] string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/ConstantMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/ConstantMapTests.cs
new file mode 100644
index 0000000..523f383
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/ConstantMapTests.cs
@@ -0,0 +1,193 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class ConstantMapTests
+ {
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("name").Constant("Bar");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsConstantSet);
+ Assert.True(map.ParameterMaps[1].Data.IsConstantSet);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.Constant);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id");
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "name").Constant("Bar");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsConstantSet);
+ Assert.True(map.ParameterMaps[1].Data.IsConstantSet);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.Constant);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]);
+ map.Parameter(constructor, parameters[1]).Constant("Bar");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsConstantSet);
+ Assert.True(map.ParameterMaps[1].Data.IsConstantSet);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.Constant);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "name" },
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_FieldMissing_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id" },
+ { "1" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_NoHeader_FieldMissing_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithParameterMap_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, "one"),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,one\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Name);
+ Parameter("id");
+ Parameter("name").Constant("Bar");
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/CultureInfoAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/CultureInfoAttributeTests.cs
new file mode 100644
index 0000000..a76883d
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/CultureInfoAttributeTests.cs
@@ -0,0 +1,119 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Threading;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class CultureInfoAttributeTests
+ {
+ private const decimal AMOUNT = 123_456.789M;
+ private const string CULTURE = "fr-FR";
+ private readonly string amount = AMOUNT.ToString(new CultureInfo(CULTURE));
+
+ [Fact]
+ public void AutoMap_WithCultureInfoAttributes_ConfiguresParameterMaps()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture);
+ var context = new CsvContext(config);
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.CultureInfo);
+ Assert.Equal(new CultureInfo(CULTURE), map.ParameterMaps[1].Data.TypeConverterOptions.CultureInfo);
+ }
+
+ [Fact]
+ public void GetRecords_WithCultureInfoAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "amount" },
+ { "1", amount },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(AMOUNT, records[0].Amount);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithCultureInfoAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", amount },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(AMOUNT, records[0].Amount);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithCultureInfoAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, AMOUNT),
+ };
+
+ var prevCulture = Thread.CurrentThread.CurrentCulture;
+ try {
+ Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Amount\r\n");
+ expected.Append($"1,{AMOUNT}\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ } finally {
+ Thread.CurrentThread.CurrentCulture = prevCulture;
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public decimal Amount { get; private set; }
+
+ public Foo(int id, [CultureInfo(CULTURE)] decimal amount)
+ {
+ Id = id;
+ Amount = amount;
+ }
+ }
+
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/CultureInfoMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/CultureInfoMapTests.cs
new file mode 100644
index 0000000..71ae189
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/CultureInfoMapTests.cs
@@ -0,0 +1,160 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Threading;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class CultureInfoMapTests
+ {
+ private const decimal AMOUNT = 123_456.789M;
+ private const string CULTURE = "fr-FR";
+ private readonly string amount = AMOUNT.ToString(new CultureInfo(CULTURE));
+
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("amount").TypeConverterOption.CultureInfo(new CultureInfo(CULTURE));
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.CultureInfo);
+ Assert.Equal(new CultureInfo(CULTURE), map.ParameterMaps[1].Data.TypeConverterOptions.CultureInfo);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id");
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "amount").TypeConverterOption.CultureInfo(new CultureInfo(CULTURE));
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.CultureInfo);
+ Assert.Equal(new CultureInfo(CULTURE), map.ParameterMaps[1].Data.TypeConverterOptions.CultureInfo);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]);
+ map.Parameter(constructor, parameters[1]).TypeConverterOption.CultureInfo(new CultureInfo(CULTURE));
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.CultureInfo);
+ Assert.Equal(new CultureInfo(CULTURE), map.ParameterMaps[1].Data.TypeConverterOptions.CultureInfo);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "amount" },
+ { "1", amount },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(AMOUNT, records[0].Amount);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", amount },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(AMOUNT, records[0].Amount);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithParameterMap_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, AMOUNT),
+ };
+
+ var prevCulture = Thread.CurrentThread.CurrentCulture;
+ try {
+ Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Amount\r\n");
+ expected.Append($"1,{AMOUNT}\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ } finally {
+ Thread.CurrentThread.CurrentCulture = prevCulture;
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public decimal Amount { get; private set; }
+
+ public Foo(int id, decimal amount)
+ {
+ Id = id;
+ Amount = amount;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Amount);
+ Parameter("id");
+ Parameter("amount").TypeConverterOption.CultureInfo(new CultureInfo(CULTURE));
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DateTimeStylesAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DateTimeStylesAttributeTests.cs
new file mode 100644
index 0000000..7207853
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DateTimeStylesAttributeTests.cs
@@ -0,0 +1,109 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class DateTimeStylesAttributeTests
+ {
+ private const string DATE = "12/25/2020";
+ private readonly DateTimeOffset date = DateTimeOffset.Parse(DATE, CultureInfo.InvariantCulture);
+
+ [Fact]
+ public void AutoMap_WithCultureInfoAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.DateTimeStyle);
+ Assert.Equal(DateTimeStyles.AllowLeadingWhite, map.ParameterMaps[1].Data.TypeConverterOptions.DateTimeStyle);
+ }
+
+ [Fact]
+ public void GetRecords_WithCultureInfoAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "date" },
+ { "1", $" {DATE}" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(date, records[0].Date);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithCultureInfoAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", $" {DATE}" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(date, records[0].Date);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithCultureInfoAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, date),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Date\r\n");
+ expected.Append($"1,{date.ToString(null, CultureInfo.InvariantCulture)}\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public DateTimeOffset Date { get; private set; }
+
+ public Foo(int id, [DateTimeStyles(DateTimeStyles.AllowLeadingWhite)] DateTimeOffset date)
+ {
+ Id = id;
+ Date = date;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DateTimeStylesMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DateTimeStylesMapTests.cs
new file mode 100644
index 0000000..d94b75f
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DateTimeStylesMapTests.cs
@@ -0,0 +1,152 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class DateTimeStylesMapTests
+ {
+ private const string DATE = "12/25/2020";
+ private readonly DateTimeOffset date = DateTimeOffset.Parse(DATE, CultureInfo.InvariantCulture);
+
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("date").TypeConverterOption.DateTimeStyles(DateTimeStyles.AllowLeadingWhite);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.DateTimeStyle);
+ Assert.Equal(DateTimeStyles.AllowLeadingWhite, map.ParameterMaps[1].Data.TypeConverterOptions.DateTimeStyle);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id");
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "date").TypeConverterOption.DateTimeStyles(DateTimeStyles.AllowLeadingWhite);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.DateTimeStyle);
+ Assert.Equal(DateTimeStyles.AllowLeadingWhite, map.ParameterMaps[1].Data.TypeConverterOptions.DateTimeStyle);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]);
+ map.Parameter(constructor, parameters[1]).TypeConverterOption.DateTimeStyles(DateTimeStyles.AllowLeadingWhite);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.DateTimeStyle);
+ Assert.Equal(DateTimeStyles.AllowLeadingWhite, map.ParameterMaps[1].Data.TypeConverterOptions.DateTimeStyle);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "date" },
+ { "1", DATE },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(date, records[0].Date);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", DATE },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(date, records[0].Date);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithParameterMap_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, date),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Date\r\n");
+ expected.Append($"1,{date.ToString(null, CultureInfo.InvariantCulture)}\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public DateTimeOffset Date { get; private set; }
+
+ public Foo(int id, DateTimeOffset date)
+ {
+ Id = id;
+ Date = date;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Date);
+ Parameter("id");
+ Parameter("date").TypeConverterOption.DateTimeStyles(DateTimeStyles.AllowLeadingWhite);
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DefaultAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DefaultAttributeTests.cs
new file mode 100644
index 0000000..226878d
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DefaultAttributeTests.cs
@@ -0,0 +1,108 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class DefaultAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithDefaultAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsDefaultSet);
+ Assert.Null(map.ParameterMaps[0].Data.Default);
+ Assert.True(map.ParameterMaps[1].Data.IsDefaultSet);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.Default);
+ }
+
+ [Fact]
+ public void GetRecords_WithDefaultAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "name" },
+ { "1", "" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithDefaultAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithDefaultAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, null),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, [Default("Bar")] string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DefaultMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DefaultMapTests.cs
new file mode 100644
index 0000000..3b6f76d
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/DefaultMapTests.cs
@@ -0,0 +1,152 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class DefaultMapTests
+ {
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("name").Default("Bar");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsDefaultSet);
+ Assert.True(map.ParameterMaps[1].Data.IsDefaultSet);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.Default);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id");
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "name").Default("Bar");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsDefaultSet);
+ Assert.True(map.ParameterMaps[1].Data.IsDefaultSet);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.Default);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]);
+ map.Parameter(constructor, parameters[1]).Default("Bar");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsDefaultSet);
+ Assert.True(map.ParameterMaps[1].Data.IsDefaultSet);
+ Assert.Equal("Bar", map.ParameterMaps[1].Data.Default);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "name" },
+ { "1", "" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithParameterMap_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, "one"),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,one\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Name);
+ Parameter("id");
+ Parameter("name").Default("Bar");
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/EnumIgnoreCaseTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/EnumIgnoreCaseTests.cs
new file mode 100644
index 0000000..af23233
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/EnumIgnoreCaseTests.cs
@@ -0,0 +1,113 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class EnumIgnoreCaseTests
+ {
+ [Fact]
+ public void AutoMap_WithEnumIgnoreCaseAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal("id", map.ParameterMaps[0].Data.Names.First());
+ Assert.Equal("bar", map.ParameterMaps[1].Data.Names.First());
+ Assert.True(map.ParameterMaps[1].Data.TypeConverterOptions.EnumIgnoreCase.GetValueOrDefault());
+ }
+
+ [Fact]
+ public void GetRecords_WithEnumIgnoreCaseAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "bar" },
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(Bar.One, records[0].Bar);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithEnumIgnoreCaseAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(Bar.One, records[0].Bar);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithIgnoreAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, Bar.None),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Bar\r\n");
+ expected.Append("1,None\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public Bar Bar { get; private set; }
+
+ public Foo(int id, [EnumIgnoreCase] Bar bar)
+ {
+ Id = id;
+ Bar = bar;
+ }
+ }
+
+ private enum Bar
+ {
+ None = 0,
+ One = 1
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/FormatAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/FormatAttributeTests.cs
new file mode 100644
index 0000000..b3fa1ac
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/FormatAttributeTests.cs
@@ -0,0 +1,111 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class FormatAttributeTests
+ {
+ private const string FORMAT = "MM|dd|yyyy";
+ private const string DATE = "12|25|2020";
+ private readonly DateTimeOffset date = DateTimeOffset.ParseExact(DATE, FORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None);
+
+ [Fact]
+ public void AutoMap_WithCultureInfoAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.Formats);
+ Assert.Single(map.ParameterMaps[1].Data.TypeConverterOptions.Formats);
+ Assert.Equal(FORMAT, map.ParameterMaps[1].Data.TypeConverterOptions.Formats[0]);
+ }
+
+ [Fact]
+ public void GetRecords_WithCultureInfoAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "date" },
+ { "1", DATE },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(date, records[0].Date);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithCultureInfoAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", DATE },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(date, records[0].Date);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithCultureInfoAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, date),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Date\r\n");
+ expected.Append($"1,{date.ToString(null, CultureInfo.InvariantCulture)}\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public DateTimeOffset Date { get; private set; }
+
+ public Foo(int id, [Format(FORMAT)] DateTimeOffset date)
+ {
+ Id = id;
+ Date = date;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/FormatMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/FormatMapTests.cs
new file mode 100644
index 0000000..673a1f7
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/FormatMapTests.cs
@@ -0,0 +1,156 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class FormatMapTests
+ {
+ private const string FORMAT = "MM|dd|yyyy";
+ private const string DATE = "12|25|2020";
+ private readonly DateTimeOffset date = DateTimeOffset.ParseExact(DATE, FORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None);
+
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("date").TypeConverterOption.Format(FORMAT);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.Formats);
+ Assert.Single(map.ParameterMaps[1].Data.TypeConverterOptions.Formats);
+ Assert.Equal(FORMAT, map.ParameterMaps[1].Data.TypeConverterOptions.Formats[0]);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id");
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "date").TypeConverterOption.Format(FORMAT);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.Formats);
+ Assert.Single(map.ParameterMaps[1].Data.TypeConverterOptions.Formats);
+ Assert.Equal(FORMAT, map.ParameterMaps[1].Data.TypeConverterOptions.Formats[0]);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]);
+ map.Parameter(constructor, parameters[1]).TypeConverterOption.Format(FORMAT);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.Formats);
+ Assert.Single(map.ParameterMaps[1].Data.TypeConverterOptions.Formats);
+ Assert.Equal(FORMAT, map.ParameterMaps[1].Data.TypeConverterOptions.Formats[0]);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "date" },
+ { "1", DATE },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(date, records[0].Date);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", DATE },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(date, records[0].Date);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithParameterMap_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, date),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Date\r\n");
+ expected.Append($"1,{date.ToString(null, CultureInfo.InvariantCulture)}\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public DateTimeOffset Date { get; private set; }
+
+ public Foo(int id, DateTimeOffset date)
+ {
+ Id = id;
+ Date = date;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Date);
+ Parameter("id");
+ Parameter("date").TypeConverterOption.Format(FORMAT);
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/HeaderPrefixAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/HeaderPrefixAttributeTests.cs
new file mode 100644
index 0000000..051f9f5
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/HeaderPrefixAttributeTests.cs
@@ -0,0 +1,111 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class HeaderPrefixAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithCultureInfoAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].ReferenceMap);
+ Assert.Equal("Bar_", map.ParameterMaps[1].ReferenceMap.Data.Prefix);
+ }
+
+ [Fact]
+ public void GetRecords_WithCultureInfoAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "Bar_Name" },
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("one", records[0].Bar.Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithCultureInfoAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("one", records[0].Bar.Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithCultureInfoAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, new Bar { Name = "one" }),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,one\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public Bar Bar { get; private set; }
+
+ public Foo(int id, [HeaderPrefix("Bar_")]Bar bar)
+ {
+ Id = id;
+ Bar = bar;
+ }
+ }
+
+ private class Bar
+ {
+ public string Name { get; set; }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/HeaderPrefixMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/HeaderPrefixMapTests.cs
new file mode 100644
index 0000000..4c5e0be
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/HeaderPrefixMapTests.cs
@@ -0,0 +1,6 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+
+// It doesn't make sense to map a prefix as you would just set the header name you want including the prefix.
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IgnoreAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IgnoreAttributeTests.cs
new file mode 100644
index 0000000..3ee4cd9
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IgnoreAttributeTests.cs
@@ -0,0 +1,106 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class IgnoreAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithIgnoreAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal("id", map.ParameterMaps[0].Data.Names.First());
+ Assert.Equal("name", map.ParameterMaps[1].Data.Names.First());
+ Assert.True(map.ParameterMaps[1].Data.Ignore);
+ }
+
+ [Fact]
+ public void GetRecords_WithIgnoreAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id" },
+ { "1" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithIgnoreAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithIgnoreAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, null),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, [CsvHelper.Configuration.Attributes.Ignore] string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IgnoreMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IgnoreMapTests.cs
new file mode 100644
index 0000000..247f4ab
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IgnoreMapTests.cs
@@ -0,0 +1,150 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class IgnoreMapTests
+ {
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("name").Ignore();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.Ignore);
+ Assert.True(map.ParameterMaps[1].Data.Ignore);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id");
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "name").Ignore();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.Ignore);
+ Assert.True(map.ParameterMaps[1].Data.Ignore);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]);
+ map.Parameter(constructor, parameters[1]).Ignore();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.Ignore);
+ Assert.True(map.ParameterMaps[1].Data.Ignore);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id" },
+ { "1" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithParameterMap_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, "one"),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,one\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Name);
+ Parameter("id");
+ Parameter("name").Ignore();
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IndexAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IndexAttributeTests.cs
new file mode 100644
index 0000000..b2a236c
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IndexAttributeTests.cs
@@ -0,0 +1,106 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class IndexAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithIndexAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal(0, map.ParameterMaps[0].Data.Index);
+ Assert.Equal(1, map.ParameterMaps[1].Data.Index);
+ }
+
+ [Fact]
+ public void GetRecords_WithIndexAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "Id", "Name" },
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("one", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithIndexAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("one", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithIndexAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, "one"),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,one\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo([Index(0)] int id, [Index(1)] string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IndexMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IndexMapTests.cs
new file mode 100644
index 0000000..fcb4c6e
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/IndexMapTests.cs
@@ -0,0 +1,149 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class IndexMapTests
+ {
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id").Index(0);
+ map.Parameter("name").Index(1);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal(0, map.ParameterMaps[0].Data.Index);
+ Assert.Equal(1, map.ParameterMaps[1].Data.Index);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id").Index(0);
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "name").Index(1);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal(0, map.ParameterMaps[0].Data.Index);
+ Assert.Equal(1, map.ParameterMaps[1].Data.Index);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]).Index(0);
+ map.Parameter(constructor, parameters[1]).Index(1);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal(0, map.ParameterMaps[0].Data.Index);
+ Assert.Equal(1, map.ParameterMaps[1].Data.Index);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "Id", "Name" },
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("one", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("one", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithParameterMap_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, "one"),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,one\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Name);
+ Parameter("id").Index(0);
+ Parameter("name").Index(1);
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameAttributeTests.cs
new file mode 100644
index 0000000..25c3586
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameAttributeTests.cs
@@ -0,0 +1,85 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class NameAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithNameAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal("Id", map.ParameterMaps[0].Data.Names[0]);
+ Assert.Equal("Name", map.ParameterMaps[1].Data.Names[0]);
+ }
+
+ [Fact]
+ public void GetRecords_WithNameAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "Id", "Name" },
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("one", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithNameAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, "one"),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,one\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo([Name("Id")] int id, [Name("Name")] string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameIndexAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameIndexAttributeTests.cs
new file mode 100644
index 0000000..55f009f
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameIndexAttributeTests.cs
@@ -0,0 +1,85 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class NameIndexAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithNameAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal(0, map.ParameterMaps[0].Data.NameIndex);
+ Assert.Equal(1, map.ParameterMaps[1].Data.NameIndex);
+ }
+
+ [Fact]
+ public void GetRecords_WithNameAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "Id", "Name", "Name" },
+ { "1", "", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("one", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithNameAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, "one"),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,one\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo([Name("Id")]int id, [Name("Name")][NameIndex(1)] string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameIndexMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameIndexMapTests.cs
new file mode 100644
index 0000000..5c8ed87
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameIndexMapTests.cs
@@ -0,0 +1,126 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class NameIndexMapTests
+ {
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id").NameIndex(0);
+ map.Parameter("name").NameIndex(1);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal(0, map.ParameterMaps[0].Data.NameIndex);
+ Assert.Equal(1, map.ParameterMaps[1].Data.NameIndex);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id").NameIndex(0);
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "name").NameIndex(1);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal(0, map.ParameterMaps[0].Data.NameIndex);
+ Assert.Equal(1, map.ParameterMaps[1].Data.NameIndex);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]).NameIndex(0);
+ map.Parameter(constructor, parameters[1]).NameIndex(1);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal(0, map.ParameterMaps[0].Data.NameIndex);
+ Assert.Equal(1, map.ParameterMaps[1].Data.NameIndex);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "Id", "Name", "Name" },
+ { "1", "", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("one", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, "one"),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,one\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Name);
+ Parameter("id").Name("Id");
+ Parameter("name").Name("Name").NameIndex(1);
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameMapTests.cs
new file mode 100644
index 0000000..0413be7
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NameMapTests.cs
@@ -0,0 +1,126 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class NameMapTests
+ {
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id").Name("Id");
+ map.Parameter("name").Name("Name");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal("Id", map.ParameterMaps[0].Data.Names[0]);
+ Assert.Equal("Name", map.ParameterMaps[1].Data.Names[0]);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id").Name("Id");
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "name").Name("Name");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal("Id", map.ParameterMaps[0].Data.Names[0]);
+ Assert.Equal("Name", map.ParameterMaps[1].Data.Names[0]);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]).Name("Id");
+ map.Parameter(constructor, parameters[1]).Name("Name");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Equal("Id", map.ParameterMaps[0].Data.Names[0]);
+ Assert.Equal("Name", map.ParameterMaps[1].Data.Names[0]);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "Id", "Name" },
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("one", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, "one"),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,one\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Name);
+ Parameter("id").Name("Id");
+ Parameter("name").Name("Name");
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NullValuesAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NullValuesAttributeTests.cs
new file mode 100644
index 0000000..0f9dd76
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NullValuesAttributeTests.cs
@@ -0,0 +1,107 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class NullValuesAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithBooleanFalseValuesAttribute_CreatesParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Empty(map.ParameterMaps[0].Data.TypeConverterOptions.NullValues);
+ Assert.Single(map.ParameterMaps[1].Data.TypeConverterOptions.NullValues);
+ Assert.Equal("NULL", map.ParameterMaps[1].Data.TypeConverterOptions.NullValues[0]);
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanFalseValuesAttribute_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "name" },
+ { "1", "NULL" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanFalseValuesAttribute_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "NULL" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithBooleanFalseValuesAttribute_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, null),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, [NullValues("NULL")] string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NullValuesMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NullValuesMapTests.cs
new file mode 100644
index 0000000..2362248
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NullValuesMapTests.cs
@@ -0,0 +1,122 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class NullValuesMapTests
+ {
+ [Fact]
+ public void AutoMap_WithBooleanFalseValuesAttribute_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("name").TypeConverterOption.NullValues("NULL");
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Empty(map.ParameterMaps[0].Data.TypeConverterOptions.NullValues);
+ Assert.Single(map.ParameterMaps[1].Data.TypeConverterOptions.NullValues);
+ Assert.Equal("NULL", map.ParameterMaps[1].Data.TypeConverterOptions.NullValues[0]);
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanFalseValuesAttribute_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ new [] { "id", "name" },
+ new [] { "1", "NULL" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithBooleanFalseValuesAttribute_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "NULL" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithBooleanFalseValuesAttribute_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, null),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Name);
+ Parameter("id");
+ Parameter("name").TypeConverterOption.NullValues("NULL");
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NumberStylesAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NumberStylesAttributeTests.cs
new file mode 100644
index 0000000..c805b41
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NumberStylesAttributeTests.cs
@@ -0,0 +1,108 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class NumberStylesAttributeTests
+ {
+ private const decimal amount = 123;
+
+ [Fact]
+ public void AutoMap_WithCultureInfoAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.NumberStyles);
+ Assert.Equal(NumberStyles.AllowParentheses, map.ParameterMaps[1].Data.TypeConverterOptions.NumberStyles);
+ }
+
+ [Fact]
+ public void GetRecords_WithCultureInfoAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "amount" },
+ { "1", $"({amount})" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(-amount, records[0].Amount);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithCultureInfoAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", $"({amount})" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(-amount, records[0].Amount);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithCultureInfoAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, amount),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Amount\r\n");
+ expected.Append($"1,{amount}\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public decimal Amount { get; private set; }
+
+ public Foo(int id, [NumberStyles(NumberStyles.AllowParentheses)] decimal amount)
+ {
+ Id = id;
+ Amount = amount;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NumberStylesMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NumberStylesMapTests.cs
new file mode 100644
index 0000000..19fdae8
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/NumberStylesMapTests.cs
@@ -0,0 +1,151 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class NumberStylesMapTests
+ {
+ private const decimal amount = 123;
+
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("amount").TypeConverterOption.NumberStyles(NumberStyles.AllowParentheses);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.NumberStyles);
+ Assert.Equal(NumberStyles.AllowParentheses, map.ParameterMaps[1].Data.TypeConverterOptions.NumberStyles);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id");
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "amount").TypeConverterOption.NumberStyles(NumberStyles.AllowParentheses);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.NumberStyles);
+ Assert.Equal(NumberStyles.AllowParentheses, map.ParameterMaps[1].Data.TypeConverterOptions.NumberStyles);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]);
+ map.Parameter(constructor, parameters[1]).TypeConverterOption.NumberStyles(NumberStyles.AllowParentheses);
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverterOptions.NumberStyles);
+ Assert.Equal(NumberStyles.AllowParentheses, map.ParameterMaps[1].Data.TypeConverterOptions.NumberStyles);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "amount" },
+ { "1", $"({amount})" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(-amount, records[0].Amount);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", $"({amount})" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal(-amount, records[0].Amount);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithParameterMap_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, amount),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Amount\r\n");
+ expected.Append($"1,{amount}\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public decimal Amount { get; private set; }
+
+ public Foo(int id, decimal amount)
+ {
+ Id = id;
+ Amount = amount;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Amount);
+ Parameter("id");
+ Parameter("amount").TypeConverterOption.NumberStyles(NumberStyles.AllowParentheses);
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/OptionalAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/OptionalAttributeTests.cs
new file mode 100644
index 0000000..2e7b8b4
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/OptionalAttributeTests.cs
@@ -0,0 +1,106 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class OptionalAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithConstantAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsOptional);
+ Assert.True(map.ParameterMaps[1].Data.IsOptional);
+ }
+
+ [Fact]
+ public void GetRecords_WithConstantAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id" },
+ { "1" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithConstantAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithConstantAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, null),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, [Optional] string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/OptionalMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/OptionalMapTests.cs
new file mode 100644
index 0000000..bae94d1
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/OptionalMapTests.cs
@@ -0,0 +1,150 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class OptionalMapTests
+ {
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("name").Optional();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsOptional);
+ Assert.True(map.ParameterMaps[1].Data.IsOptional);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id");
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "name").Optional();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsOptional);
+ Assert.True(map.ParameterMaps[1].Data.IsOptional);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]);
+ map.Parameter(constructor, parameters[1]).Optional();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.False(map.ParameterMaps[0].Data.IsOptional);
+ Assert.True(map.ParameterMaps[1].Data.IsOptional);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id" },
+ { "1" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Null(records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithParameterMap_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, null),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Name);
+ Parameter("id");
+ Parameter("name").Optional();
+ }
+ }
+
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/TypeConverterAttributeTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/TypeConverterAttributeTests.cs
new file mode 100644
index 0000000..4d6cd2a
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/TypeConverterAttributeTests.cs
@@ -0,0 +1,115 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Configuration.Attributes;
+using CsvHelper.Tests.Mocks;
+using CsvHelper.TypeConversion;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class TypeConverterAttributeTests
+ {
+ [Fact]
+ public void AutoMap_WithConstantAttributes_ConfiguresParameterMaps()
+ {
+ var context = new CsvContext(new CsvConfiguration(CultureInfo.InvariantCulture));
+ var map = context.AutoMap<Foo>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.IsType<Int32Converter>(map.ParameterMaps[0].Data.TypeConverter);
+ Assert.IsType<CustomConverter>(map.ParameterMaps[1].Data.TypeConverter);
+ }
+
+ [Fact]
+ public void GetRecords_WithConstantAttributes_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "name" },
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithConstantAttributes_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithConstantAttributes_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, null),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, [TypeConverter(typeof(CustomConverter))] string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+
+ private class CustomConverter : DefaultTypeConverter
+ {
+ public override object ConvertFromString(string text, IReaderRow row, MemberMapData memberMapData)
+ {
+ return "Bar";
+ }
+ }
+ }
+}
diff --git a/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/TypeConverterMapTests.cs b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/TypeConverterMapTests.cs
new file mode 100644
index 0000000..98bc4dd
--- /dev/null
+++ b/ThirdParty/CsvHelper-master/tests/CsvHelper.Tests/Mappings/ConstructorParameter/TypeConverterMapTests.cs
@@ -0,0 +1,158 @@
+// Copyright 2009-2022 Josh Close
+// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
+// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
+// https://github.com/JoshClose/CsvHelper
+using CsvHelper.Configuration;
+using CsvHelper.Tests.Mocks;
+using CsvHelper.TypeConversion;
+using Xunit;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CsvHelper.Tests.Mappings.ConstructorParameter
+{
+
+ public class TypeConverterMapTests
+ {
+ [Fact]
+ public void Parameter_WithName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter("id");
+ map.Parameter("name").TypeConverter<CustomConverter>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverter);
+ Assert.IsType<CustomConverter>(map.ParameterMaps[1].Data.TypeConverter);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorFunctionAndName_CreatesParameterMaps()
+ {
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "id");
+ map.Parameter(() => ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo))), "name").TypeConverter<CustomConverter>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverter);
+ Assert.IsType<CustomConverter>(map.ParameterMaps[1].Data.TypeConverter);
+ }
+
+ [Fact]
+ public void Parameter_WithConstructorAndProperty_CreatesParameterMaps()
+ {
+ var constructor = ConfigurationFunctions.GetConstructor(new GetConstructorArgs(typeof(Foo)));
+ var parameters = constructor.GetParameters();
+
+ var map = new DefaultClassMap<Foo>();
+ map.Parameter(constructor, parameters[0]);
+ map.Parameter(constructor, parameters[1]).TypeConverter<CustomConverter>();
+
+ Assert.Equal(2, map.ParameterMaps.Count);
+ Assert.Null(map.ParameterMaps[0].Data.TypeConverter);
+ Assert.IsType<CustomConverter>(map.ParameterMaps[1].Data.TypeConverter);
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_HasHeader_CreatesRecords()
+ {
+ var parser = new ParserMock
+ {
+ { "id", "name" },
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ var map = csv.Context.RegisterClassMap<FooMap>();
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void GetRecords_WithParameterMap_NoHeader_CreatesRecords()
+ {
+ var config = new CsvConfiguration(CultureInfo.InvariantCulture)
+ {
+ HasHeaderRecord = false,
+ };
+ var parser = new ParserMock(config)
+ {
+ { "1", "one" },
+ };
+ using (var csv = new CsvReader(parser))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ var records = csv.GetRecords<Foo>().ToList();
+
+ Assert.Single(records);
+ Assert.Equal(1, records[0].Id);
+ Assert.Equal("Bar", records[0].Name);
+ }
+ }
+
+ [Fact]
+ public void WriteRecords_WithParameterMap_DoesntUseParameterMaps()
+ {
+ var records = new List<Foo>
+ {
+ new Foo(1, "one"),
+ };
+
+ using (var writer = new StringWriter())
+ using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
+ {
+ csv.Context.RegisterClassMap<FooMap>();
+
+ csv.WriteRecords(records);
+
+ var expected = new StringBuilder();
+ expected.Append("Id,Name\r\n");
+ expected.Append("1,one\r\n");
+
+ Assert.Equal(expected.ToString(), writer.ToString());
+ }
+ }
+
+ private class Foo
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; }
+
+ public Foo(int id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+
+ private class FooMap : ClassMap<Foo>
+ {
+ public FooMap()
+ {
+ Map(m => m.Id);
+ Map(m => m.Name);
+ Parameter("id");
+ Parameter("name").TypeConverter<CustomConverter>();
+ }
+ }
+
+ private class CustomConverter : DefaultTypeConverter
+ {
+ public override object ConvertFromString(string text, IReaderRow row, MemberMapData memberMapData)
+ {
+ return "Bar";
+ }
+ }
+ }
+}