Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/CriticalProfileProperties.cs
===================================================================
diff -u -re41a8cc75ec6e93aee52452aa50f47638a044feb -reaea0250dbe34b6f82f083bcccdee495639d6d02
--- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/CriticalProfileProperties.cs (.../CriticalProfileProperties.cs) (revision e41a8cc75ec6e93aee52452aa50f47638a044feb)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/CriticalProfileProperties.cs (.../CriticalProfileProperties.cs) (revision eaea0250dbe34b6f82f083bcccdee495639d6d02)
@@ -35,7 +35,7 @@
internal class CriticalProfileProperties
{
///
- /// Creates a new instance of , which contains properties
+ /// Creates a new instance of which contains properties
/// that are critical for reading profiles. If these properties cannot be read, then something
/// went wrong while querying the database.
///
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs
===================================================================
diff -u -re41a8cc75ec6e93aee52452aa50f47638a044feb -reaea0250dbe34b6f82f083bcccdee495639d6d02
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs (.../CriticalProfilePropertiesTest.cs) (revision e41a8cc75ec6e93aee52452aa50f47638a044feb)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs (.../CriticalProfilePropertiesTest.cs) (revision eaea0250dbe34b6f82f083bcccdee495639d6d02)
@@ -72,14 +72,43 @@
}
[Test]
- public void Constructor_WithReaderInvalidProfileName_SetProperties()
+ public void Constructor_WithReaderInvalidProfileId_ThrowsCriticalFileReadException()
{
// Setup
var reader = mocks.StrictMock();
+ const string profileName = "profile";
const int layerCount = 1;
const string path = "A";
var invalidCastException = new InvalidCastException();
+ reader.Expect(r => r.Read(SoilProfileTableDefinitions.ProfileName)).IgnoreArguments().Return(profileName);
+ reader.Expect(r => r.Read(SoilProfileTableDefinitions.LayerCount)).IgnoreArguments().Return(layerCount);
+ reader.Expect(r => r.Read(SoilProfileTableDefinitions.SoilProfileId)).IgnoreArguments().Throw(invalidCastException);
+ reader.Expect(r => r.Path).Return(path);
+
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => new CriticalProfileProperties(reader);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreSame(invalidCastException, exception.InnerException);
+ string expectedMessage = new FileReaderErrorMessageBuilder(path)
+ .WithSubject($"ondergrondschematisatie '{profileName}'")
+ .Build("Kritieke fout opgetreden bij het uitlezen van waardes uit kolommen in de database.");
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
+ public void Constructor_WithReaderInvalidProfileName_ThrowsCriticalFileReadException()
+ {
+ // Setup
+ var reader = mocks.StrictMock();
+ const int layerCount = 1;
+ const string path = "A";
+ var invalidCastException = new InvalidCastException();
+
reader.Expect(r => r.Read(SoilProfileTableDefinitions.ProfileName)).IgnoreArguments().Throw(invalidCastException);
reader.Expect(r => r.Read(SoilProfileTableDefinitions.LayerCount)).IgnoreArguments().Return(layerCount).Repeat.Any();
reader.Expect(r => r.Path).Return(path);
@@ -98,7 +127,7 @@
}
[Test]
- public void Constructor_WithReaderInvalidLayerCount_SetProperties()
+ public void Constructor_WithReaderInvalidLayerCount_ThrowsCriticalFileReadException()
{
// Setup
var reader = mocks.StrictMock();