From e6ed504a303766f61deeef60fcc537fdbd612a85 Mon Sep 17 00:00:00 2001 From: samatstarion Date: Sun, 8 Dec 2024 12:13:59 +0100 Subject: [PATCH] [Rename] CsvReader.Read to CsvReader.ReadAsync [Rename] IterationReader.Read to IterationReader.ReadAsync --- DEH-CSV.Tests/CsvReaderTestFixture.cs | 2 +- DEH-CSV.Tests/CsvWriterTestFixture.cs | 4 ++-- .../ThingTimeStampedCSVWriterTestFixture.cs | 2 +- DEH-CSV.Tests/Services/IterationReaderTestFixture.cs | 8 ++++---- DEH-CSV/CsvReader.cs | 12 +++++++----- DEH-CSV/ICsvReader.cs | 2 +- DEH-CSV/Services/IIterationReader.cs | 4 ++-- DEH-CSV/Services/IterationReader.cs | 4 ++-- 8 files changed, 20 insertions(+), 18 deletions(-) diff --git a/DEH-CSV.Tests/CsvReaderTestFixture.cs b/DEH-CSV.Tests/CsvReaderTestFixture.cs index fd13f36..e6b7d1d 100644 --- a/DEH-CSV.Tests/CsvReaderTestFixture.cs +++ b/DEH-CSV.Tests/CsvReaderTestFixture.cs @@ -113,7 +113,7 @@ public async Task VerifyCsvReaderImplementation() var domain = loftModel.Participant.Single(x => x.Person == this.session.ActivePerson).SelectedDomain; await this.session.Read(iteration, domain); - var mappedThings = (await this.csvReader.Read(csvStream, typeMaps.ToList(), this.session)).ToList(); + var mappedThings = (await this.csvReader.ReadAsync(csvStream, typeMaps.ToList(), this.session)).ToList(); Assert.Multiple(() => { diff --git a/DEH-CSV.Tests/CsvWriterTestFixture.cs b/DEH-CSV.Tests/CsvWriterTestFixture.cs index f1002e4..fae476a 100644 --- a/DEH-CSV.Tests/CsvWriterTestFixture.cs +++ b/DEH-CSV.Tests/CsvWriterTestFixture.cs @@ -92,7 +92,7 @@ public async Task Verify_that_demosat_model_can_be_written_to_CSV_file() await session.Open(false); - var iteration = await this.iterationReader.Read(session, "DM_SPC", 1, "SYS"); + var iteration = await this.iterationReader.ReadAsync(session, "DM_SPC", 1, "SYS"); var outputPath = Path.Combine(TestContext.CurrentContext.WorkDirectory, "CSV"); var target = new DirectoryInfo(outputPath); @@ -117,7 +117,7 @@ public async Task Verify_that_when_ValuePrefix_is_set_CSV_File_is_Written_with_p await session.Open(false); - var iteration = await this.iterationReader.Read(session, "DM_SPC", 1, "SYS"); + var iteration = await this.iterationReader.ReadAsync(session, "DM_SPC", 1, "SYS"); var typeMaps = new List { diff --git a/DEH-CSV.Tests/CustomProperties/ThingTimeStampedCSVWriterTestFixture.cs b/DEH-CSV.Tests/CustomProperties/ThingTimeStampedCSVWriterTestFixture.cs index 970a3c1..73e79f9 100644 --- a/DEH-CSV.Tests/CustomProperties/ThingTimeStampedCSVWriterTestFixture.cs +++ b/DEH-CSV.Tests/CustomProperties/ThingTimeStampedCSVWriterTestFixture.cs @@ -86,7 +86,7 @@ public async Task Verify_that_demosat_model_can_be_written_to_CSV_file() await session.Open(false); - var iteration = await this.iterationReader.Read(session, "DM_SPC", 1, "SYS"); + var iteration = await this.iterationReader.ReadAsync(session, "DM_SPC", 1, "SYS"); var outputPath = Path.Combine(TestContext.CurrentContext.WorkDirectory, "CSV-Thing-TimeStamped"); var target = new DirectoryInfo(outputPath); diff --git a/DEH-CSV.Tests/Services/IterationReaderTestFixture.cs b/DEH-CSV.Tests/Services/IterationReaderTestFixture.cs index 2eec4d0..2a8e85c 100644 --- a/DEH-CSV.Tests/Services/IterationReaderTestFixture.cs +++ b/DEH-CSV.Tests/Services/IterationReaderTestFixture.cs @@ -76,7 +76,7 @@ public async Task Verify_that_iteration_can_be_read_from_data_source_demo_space( await session.Open(false); - var iteration = await this.iterationReader.Read(session, "DM_SPC", 1, "SYS"); + var iteration = await this.iterationReader.ReadAsync(session, "DM_SPC", 1, "SYS"); Assert.That(iteration, Is.Not.Null); } @@ -96,13 +96,13 @@ public async Task Verify_that_iteration_read_throws_expected_exceptions() await session.Open(false); - Assert.That(async () => await this.iterationReader.Read(session, "XXX", 1, "SYS"), + Assert.That(async () => await this.iterationReader.ReadAsync(session, "XXX", 1, "SYS"), Throws.Exception.With.Message.EqualTo("The EngineeringModelSetup with shortName XXX could not be found")); - Assert.That(async () => await this.iterationReader.Read(session, "DM_SPC", 12, "SYS"), + Assert.That(async () => await this.iterationReader.ReadAsync(session, "DM_SPC", 12, "SYS"), Throws.Exception.With.Message.EqualTo("The IterationSetup with number 12 could not be found")); - Assert.That(async () => await this.iterationReader.Read(session, "DM_SPC", 1, "SYE"), + Assert.That(async () => await this.iterationReader.ReadAsync(session, "DM_SPC", 1, "SYE"), Throws.Exception.With.Message.EqualTo("The DomainOfExpertise with shortName SYE could not be found")); } } diff --git a/DEH-CSV/CsvReader.cs b/DEH-CSV/CsvReader.cs index df39182..4410d27 100644 --- a/DEH-CSV/CsvReader.cs +++ b/DEH-CSV/CsvReader.cs @@ -71,7 +71,7 @@ public CsvReader(ILogger logger) /// The collection of s /// The that helps to retrieve /// A that returns a collection of mapped s - public async Task> Read(Stream stream, IReadOnlyCollection typeMaps, ISession session) + public async Task> ReadAsync(Stream stream, IReadOnlyCollection typeMaps, ISession session) { ValidateReadParameters(stream, typeMaps, session); @@ -90,7 +90,7 @@ public async Task> Read(Stream stream, IReadOnlyCollection previousThings, } break; + default: + throw new InvalidDataException("The referenced value is not a Thing or IEnumerable"); } } @@ -434,7 +436,7 @@ private void ValidateEntryPoint(TypeMap typeMap, PropertyMap entryPoint) /// The used to read CSV content /// The collection of s /// A - private async Task ReadHeader(IReader reader, IEnumerable typeMaps) + private async Task ReadHeaderAsync(IReader reader, IEnumerable typeMaps) { await reader.ReadAsync(); @@ -446,7 +448,7 @@ private async Task ReadHeader(IReader reader, IEnumerable typeMaps) var headers = reader.HeaderRecord; - if (typeMaps.SelectMany(x => x.Properties).FirstOrDefault(p => Array.TrueForAll(headers, x => !x.Equals(p.Source))) is { } invalidPropertyMap) + if (typeMaps.SelectMany(x => x.Properties).FirstOrDefault(p => Array.TrueForAll(headers, x => !x.Equals(p.Source, StringComparison.Ordinal))) is { } invalidPropertyMap) { this.logger.LogError("The provided CSV does not contains any header for the source {0}", invalidPropertyMap.Source); throw new InvalidDataException($"The provided CSV does not contains any header for the source {invalidPropertyMap.Source}"); @@ -454,7 +456,7 @@ private async Task ReadHeader(IReader reader, IEnumerable typeMaps) } /// - /// Validates all parameters provided for the method + /// Validates all parameters provided for the method /// /// The provided /// The provided collection of s diff --git a/DEH-CSV/ICsvReader.cs b/DEH-CSV/ICsvReader.cs index cb6680b..ffb4193 100644 --- a/DEH-CSV/ICsvReader.cs +++ b/DEH-CSV/ICsvReader.cs @@ -44,6 +44,6 @@ public interface ICsvReader /// The collection of s /// The that helps to retrieve /// A that returns a collection of mapped s - Task> Read(Stream stream, IReadOnlyCollection typeMaps, ISession session); + Task> ReadAsync(Stream stream, IReadOnlyCollection typeMaps, ISession session); } } diff --git a/DEH-CSV/Services/IIterationReader.cs b/DEH-CSV/Services/IIterationReader.cs index e114e4d..d2aefca 100644 --- a/DEH-CSV/Services/IIterationReader.cs +++ b/DEH-CSV/Services/IIterationReader.cs @@ -34,7 +34,7 @@ namespace STARIONGROUP.DEHCSV.Services public interface IIterationReader { /// - /// Read the iteration from the + /// ReadAsync the iteration from the /// /// /// The object used to read the data @@ -51,6 +51,6 @@ public interface IIterationReader /// /// An instance of /// - Task Read(ISession session, string modelShortName, int iterationNumber, string domainOfExpertiseShortName); + Task ReadAsync(ISession session, string modelShortName, int iterationNumber, string domainOfExpertiseShortName); } } diff --git a/DEH-CSV/Services/IterationReader.cs b/DEH-CSV/Services/IterationReader.cs index 2cbd63d..e6b237b 100644 --- a/DEH-CSV/Services/IterationReader.cs +++ b/DEH-CSV/Services/IterationReader.cs @@ -56,7 +56,7 @@ public IterationReader(ILoggerFactory loggerFactory = null) } /// - /// Read the iteration from the + /// ReadAsync the iteration from the /// /// /// The object used to read the data @@ -73,7 +73,7 @@ public IterationReader(ILoggerFactory loggerFactory = null) /// /// An instance of /// - public async Task Read(ISession session, string modelShortName, int iterationNumber, string domainOfExpertiseShortName) + public async Task ReadAsync(ISession session, string modelShortName, int iterationNumber, string domainOfExpertiseShortName) { this.logger.LogDebug("Setting up the read request for {modelShortName}:{iterationNumber}", modelShortName, iterationNumber);