Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilLayerData.cs =================================================================== diff -u -r9e2f9f7fe2d7daf45c943fc446cd9edc4298290d -r1f93a84f1b02a111e18915ffb0ae2d46b54ed778 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilLayerData.cs (.../MacroStabilityInwardsSoilLayerData.cs) (revision 9e2f9f7fe2d7daf45c943fc446cd9edc4298290d) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilLayerData.cs (.../MacroStabilityInwardsSoilLayerData.cs) (revision 1f93a84f1b02a111e18915ffb0ae2d46b54ed778) @@ -38,7 +38,7 @@ private readonly VariationCoefficientLogNormalDistribution strengthIncreaseExponent; private readonly VariationCoefficientLogNormalDistribution shearStrengthRatio; private readonly VariationCoefficientLogNormalDistribution pop; - private string materialName = string.Empty; + private string materialName = "Material"; /// /// Creates a new instance of . @@ -94,7 +94,13 @@ /// /// Gets or sets the name of the material that was assigned to the layer. /// - /// Thrown when is null. + /// Thrown when is: + /// + /// null; + /// empty; + /// only containing white spaces. + /// + /// public string MaterialName { get @@ -103,10 +109,11 @@ } set { - if (value == null) + if (string.IsNullOrWhiteSpace(value)) { - throw new ArgumentNullException(nameof(value)); + throw new ArgumentException("Material name must not be empty"); } + materialName = value; } } Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilLayerDataTest.cs =================================================================== diff -u -rd9005dfa3b398d70ada0cf03cf408f8bcfc384db -r1f93a84f1b02a111e18915ffb0ae2d46b54ed778 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilLayerDataTest.cs (.../MacroStabilityInwardsSoilLayerDataTest.cs) (revision d9005dfa3b398d70ada0cf03cf408f8bcfc384db) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilLayerDataTest.cs (.../MacroStabilityInwardsSoilLayerDataTest.cs) (revision 1f93a84f1b02a111e18915ffb0ae2d46b54ed778) @@ -42,7 +42,7 @@ // Assert Assert.IsFalse(data.IsAquifer); - Assert.IsEmpty(data.MaterialName); + Assert.AreEqual("Material", data.MaterialName); Assert.AreEqual(Color.Empty, data.Color); Assert.IsFalse(data.UsePop); @@ -94,7 +94,7 @@ } [Test] - public void MaterialName_Null_ThrowsArgumentNullException() + public void MaterialName_Null_ThrowsArgumentException() { // Setup var data = new MacroStabilityInwardsSoilLayerData(); @@ -103,14 +103,42 @@ TestDelegate test = () => data.MaterialName = null; // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("value", paramName); + string message = Assert.Throws(test).Message; + Assert.AreEqual("Material name must not be empty", message); } [Test] - [TestCase("")] + public void MaterialName_Empty_ThrowsArgumentException() + { + // Setup + var data = new MacroStabilityInwardsSoilLayerData(); + + // Call + TestDelegate test = () => data.MaterialName = string.Empty; + + // Assert + string message = Assert.Throws(test).Message; + Assert.AreEqual("Material name must not be empty", message); + } + + [Test] + public void MaterialName_WhiteSpace_ThrowsArgumentException() + { + // Setup + var data = new MacroStabilityInwardsSoilLayerData(); + + // Call + TestDelegate test = () => data.MaterialName = " "; + + // Assert + string message = Assert.Throws(test).Message; + Assert.AreEqual("Material name must not be empty", message); + } + + [Test] [TestCase("A name")] - public void MaterialName_NotNullValue_ValueSet(string materialName) + [TestCase("123")] + public void MaterialName_ValidValue_ValueSet(string materialName) { // Setup var data = new MacroStabilityInwardsSoilLayerData();