Skip to content

Commit

Permalink
Merge pull request #6 from akesseler/Support_CRLF_in_strings
Browse files Browse the repository at this point in the history
Support of line breaks within strings.
  • Loading branch information
akesseler committed Aug 16, 2024
2 parents a38e9a0 + 454e944 commit d5bef99
Show file tree
Hide file tree
Showing 54 changed files with 535 additions and 321 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright (c) 2022 plexdata.de
Copyright (c) 2024 plexdata.de

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions code/hlp/Plexdata.CsvParser.NET.help.shfbproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<IndentHtml>False</IndentHtml>
<BuildAssemblerVerbosity>OnlyWarningsAndErrors</BuildAssemblerVerbosity>
<HelpTitle>Plexdata.CsvParser.NET</HelpTitle>
<HelpFileVersion>1.1.2</HelpFileVersion>
<HelpFileVersion>1.1.3</HelpFileVersion>
<NamingMethod>Guid</NamingMethod>
<ContentPlacement>AboveNamespaces</ContentPlacement>
<RootNamespaceContainer>True</RootNamespaceContainer>
Expand Down Expand Up @@ -78,7 +78,7 @@
<Argument Key="baseSourceCodeUrl" Value="" />
<Argument Key="requestExampleUrl" Value="" />
</TransformComponentArguments>
<CopyrightText>Copyright &amp;#169%3b 2022 - plexdata.de</CopyrightText>
<CopyrightText>Copyright &amp;#169%3b 2024 - plexdata.de</CopyrightText>
<CopyrightHref>http://www.plexdata.de/</CopyrightHref>
<NamespaceSummaries>
</NamespaceSummaries>
Expand Down
4 changes: 2 additions & 2 deletions code/hlp/Plexdata.CsvParser.NET.wiki.shfbproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<IndentHtml>False</IndentHtml>
<BuildAssemblerVerbosity>OnlyWarningsAndErrors</BuildAssemblerVerbosity>
<HelpTitle>Plexdata.CsvParser.NET</HelpTitle>
<HelpFileVersion>1.1.2</HelpFileVersion>
<HelpFileVersion>1.1.3</HelpFileVersion>
<NamingMethod>Guid</NamingMethod>
<ContentPlacement>AboveNamespaces</ContentPlacement>
<RootNamespaceContainer>True</RootNamespaceContainer>
Expand Down Expand Up @@ -78,7 +78,7 @@
<Argument Key="baseSourceCodeUrl" Value="" />
<Argument Key="requestExampleUrl" Value="" />
</TransformComponentArguments>
<CopyrightText>Copyright &amp;#169%3b 2022 - plexdata.de</CopyrightText>
<CopyrightText>Copyright &amp;#169%3b 2024 - plexdata.de</CopyrightText>
<CopyrightHref>http://www.plexdata.de/</CopyrightHref>
<NamespaceSummaries>
</NamespaceSummaries>
Expand Down
9 changes: 9 additions & 0 deletions code/src/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@


**1.1.3**
- Support of line breaks within strings.
- Update of user documentation.
- Update of test framework packages.
- Version number increased.
- Copyright year changed to 2024 in all files.
- Wiki and release update on _GitHub_.
- Package release on `nuget.org`.

**1.1.2**
- New features added to class `CsvContainer`, such as
- New method `Contains` to query a header existence.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2022 plexdata.de
* Copyright (c) 2024 plexdata.de
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,46 +24,48 @@

using NUnit.Framework;
using Plexdata.CsvParser.Attributes;
using Plexdata.Utilities.Testing;
using System;
using System.Diagnostics.CodeAnalysis;

namespace Plexdata.CsvParser.Tests.Attributes
{
[TestFixture]
[ExcludeFromCodeCoverage]
[Category(TestType.UnitTest)]
[TestOf(nameof(CsvColumnAttribute))]
public class CsvColumnAttributeTests
{
[Test]
public void Construction_DefaultConstructor_ResultDoesNotThrow()
{
Assert.DoesNotThrow(() => { new CsvColumnAttribute(); });
Assert.That(() => new CsvColumnAttribute(), Throws.Nothing);
}

[Test]
public void Construction_DefaultConstructor_ResultIsTrue()
{
CsvColumnAttribute attribute = new CsvColumnAttribute();
Assert.IsTrue(attribute.Header == String.Empty && attribute.Offset == -1);
Assert.That(attribute.Header == String.Empty && attribute.Offset == -1, Is.True);
}

[Test]
[TestCase(null)]
[TestCase("")]
[TestCase("test-header")]
public void Header_SetValue_ResultAreEqual(String expected)
{
CsvColumnAttribute attribute = new CsvColumnAttribute();
attribute.Header = expected;
Assert.AreEqual(expected, attribute.Header);
Assert.That(attribute.Header, Is.EqualTo(expected));
}

[Test]
[TestCase(-42)]
[TestCase(42)]
public void Offset_SetValue_ResultAreEqual(Int32 expected)
{
CsvColumnAttribute attribute = new CsvColumnAttribute();
attribute.Offset = expected;
Assert.AreEqual(expected, attribute.Offset);
Assert.That(attribute.Offset, Is.EqualTo(expected));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2022 plexdata.de
* Copyright (c) 2024 plexdata.de
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,17 +24,21 @@

using NUnit.Framework;
using Plexdata.CsvParser.Attributes;
using Plexdata.Utilities.Testing;
using System.Diagnostics.CodeAnalysis;

namespace Plexdata.CsvParser.Tests.Attributes
{
[TestFixture]
[ExcludeFromCodeCoverage]
[Category(TestType.UnitTest)]
[TestOf(nameof(CsvDocumentAttribute))]
public class CsvDocumentAttributeTests
{
[Test]
public void Construction_DefaultConstructor_ResultDoesNotThrow()
{
Assert.DoesNotThrow(() => { new CsvDocumentAttribute(); });
Assert.That(() => new CsvDocumentAttribute(), Throws.Nothing);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2022 plexdata.de
* Copyright (c) 2024 plexdata.de
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,17 +24,21 @@

using NUnit.Framework;
using Plexdata.CsvParser.Attributes;
using Plexdata.Utilities.Testing;
using System.Diagnostics.CodeAnalysis;

namespace Plexdata.CsvParser.Tests.Attributes
{
[TestFixture]
[ExcludeFromCodeCoverage]
[Category(TestType.UnitTest)]
[TestOf(nameof(CsvIgnoreAttribute))]
public class CsvIgnoreAttributeTests
{
[Test]
public void Construction_DefaultConstructor_ResultDoesNotThrow()
{
Assert.DoesNotThrow(() => { new CsvIgnoreAttribute(); });
Assert.That(() => new CsvIgnoreAttribute(), Throws.Nothing);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2022 plexdata.de
* Copyright (c) 2024 plexdata.de
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,23 +24,26 @@

using NUnit.Framework;
using Plexdata.CsvParser.Constants;
using Plexdata.Utilities.Testing;
using System;
using System.Diagnostics.CodeAnalysis;

namespace Plexdata.CsvParser.Tests.Constants
{
[TestFixture]
[ExcludeFromCodeCoverage]
[Category(TestType.UnitTest)]
[TestOf(nameof(ColumnSeparators))]
public class ColumnSeparatorsTests
{
[Test]
[TestCase(':', ColumnSeparators.ColonSeparator)]
[TestCase(',', ColumnSeparators.CommaSeparator)]
[TestCase(';', ColumnSeparators.SemicolonSeparator)]
[TestCase('\t', ColumnSeparators.TabulatorSeparator)]
[TestCase(',', ColumnSeparators.DefaultSeparator)]
public void Verification_ColumnSeparators_ResultAreEqual(Char expected, Char actual)
{
Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2022 plexdata.de
* Copyright (c) 2024 plexdata.de
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,15 +26,18 @@
using Plexdata.CsvParser.Definitions;
using Plexdata.CsvParser.Extensions;
using Plexdata.CsvParser.Processors;
using Plexdata.Utilities.Testing;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text;

namespace Plexdata.CsvParser.Tests.Extensions
{
[TestFixture]
[ExcludeFromCodeCoverage]
[Category(TestType.IntegrationTest)]
[TestOf(nameof(CsvContainerExtension))]
[Category(TestHelper.IntegrationTest)]
public class CsvContainerExtensionTests
{
[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2022 plexdata.de
* Copyright (c) 2024 plexdata.de
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,42 +25,44 @@
using NUnit.Framework;
using Plexdata.CsvParser.Attributes;
using Plexdata.CsvParser.Internals;
using Plexdata.Utilities.Testing;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;

namespace Plexdata.CsvParser.Tests.Internals
{
[TestFixture]
[ExcludeFromCodeCoverage]
[Category(TestType.UnitTest)]
[TestOf(nameof(ItemDescriptor))]
public class ItemDescriptorTests
{
[Test]
[TestCase(0, 0)]
[TestCase(0, 1)]
[TestCase(1, 0)]
public void Construction_ItemDescriptor_ThrowsArgumentNullException(Int32 column, Int32 origin)
{
Assert.Throws<ArgumentNullException>(() => { new ItemDescriptor(column == 0 ? null : new CsvColumnAttribute(), origin == 0 ? null : new PropertyInfoTest()); });
Assert.That(() => new ItemDescriptor(column == 0 ? null : new CsvColumnAttribute(), origin == 0 ? null : new PropertyInfoTest()), Throws.ArgumentNullException);
}

[Test]
public void Construction_ItemDescriptor_ResultIsColumnAreEqual()
{
CsvColumnAttribute column = new CsvColumnAttribute();
ItemDescriptor actual = new ItemDescriptor(column, new PropertyInfoTest());
Assert.AreEqual(column, actual.Column);
Assert.That(actual.Column, Is.EqualTo(column));
}

[Test]
public void Construction_ItemDescriptor_ResultIsOriginAreEqual()
{
PropertyInfoTest origin = new PropertyInfoTest();
ItemDescriptor actual = new ItemDescriptor(new CsvColumnAttribute(), origin);
Assert.AreEqual(origin, actual.Origin);
Assert.That(actual.Origin, Is.EqualTo(origin));
}

[Test]
[TestCase("CanNeverBeNull", null, -1)]
[TestCase("CanNeverBeNull", "", -1)]
[TestCase("CanNeverBeNull", " \t \r\n \v", -1)]
Expand All @@ -76,7 +78,7 @@ public void ToString_ItemDescriptor_ResultAreEqual(String originName, String hea
CsvColumnAttribute column = new CsvColumnAttribute { Header = $"{headerName}", Offset = offsetValue, };
String expected = $"Offset: \"{offsetValue}\", Header: \"{headerName}\", Origin: \"{originName}\"";
ItemDescriptor actual = new ItemDescriptor(column, origin);
Assert.AreEqual(expected, actual.ToString());
Assert.That(actual.ToString(), Is.EqualTo(expected));
}

private class PropertyInfoTest : PropertyInfo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2022 plexdata.de
* Copyright (c) 2024 plexdata.de
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,18 +25,21 @@
using NUnit.Framework;
using Plexdata.CsvParser.Internals;
using Plexdata.CsvParser.Processors;
using Plexdata.Utilities.Testing;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;

namespace Plexdata.CsvParser.Tests.Internals
{
[TestFixture]
[ExcludeFromCodeCoverage]
[Category(TestType.UnitTest)]
[TestOf(nameof(ProcessHelper))]
public class ProcessHelperTests
{
[Test]
[TestCaseSource(nameof(SplitIntoCellsTestCases))]
public void SplitIntoCells_VariousValueCombinations_ResultAsExpected(Object data)
{
Expand All @@ -47,7 +50,6 @@ public void SplitIntoCells_VariousValueCombinations_ResultAsExpected(Object data
Assert.That(String.Join(String.Empty, actual), Is.EqualTo(String.Join(String.Empty, item.Expected)));
}

[Test]
[TestCase("Quoting on", true)]
[TestCase(42, false)]
public void ConvertToString_QuotingIsTrueForStrings_ResultAsExpected(Object value, Boolean expected)
Expand All @@ -60,7 +62,6 @@ public void ConvertToString_QuotingIsTrueForStrings_ResultAsExpected(Object valu
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
[TestCase(null, ':', false, ":")]
[TestCase(null, ':', true, "\"\":")]
[TestCase("\"", ':', false, "\"\"\"\":")]
Expand Down Expand Up @@ -114,7 +115,6 @@ public void FixupOutput_StringBuilderIsEmpty_ResultIsEmpty()
Assert.That(ProcessHelper.FixupOutput(new StringBuilder(), '#').Length, Is.EqualTo(0));
}

[Test]
[TestCase("some data", '#', "some data")]
[TestCase("some data#", '#', "some data")]
[TestCase("some#data", '#', "some#data")]
Expand Down
Loading

0 comments on commit d5bef99

Please sign in to comment.