Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/AssessmentSection/BackgroundDataTest.cs =================================================================== diff -u -rc0387d79bcdc500558362264d5bc08834ebe6db5 -r68e06c08cb60c1c42e5c3b03fd3af070748a6bca --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/AssessmentSection/BackgroundDataTest.cs (.../BackgroundDataTest.cs) (revision c0387d79bcdc500558362264d5bc08834ebe6db5) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/AssessmentSection/BackgroundDataTest.cs (.../BackgroundDataTest.cs) (revision 68e06c08cb60c1c42e5c3b03fd3af070748a6bca) @@ -20,6 +20,8 @@ // All rights reserved. using System; +using System.Collections.Generic; +using System.Linq; using Core.Common.Base.Data; using Core.Common.TestUtil; using NUnit.Framework; @@ -84,5 +86,65 @@ string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message).ParamName; Assert.AreEqual("value", paramName); } + + [Test] + [TestCase("SourceCapabilitiesUrl")] + [TestCase("SelectedCapabilityIdentifier")] + [TestCase("PreferredFormat")] + [TestCase("WellKnownTileSource")] + public void Parameters_AllowedKeys_ItemAddedToDictionary(string allowedKey) + { + // Setup + const string value = "some value"; + var backgroundData = new BackgroundData(); + + // Precondition + CollectionAssert.IsEmpty(backgroundData.Parameters); + + // Call + backgroundData.Parameters.Add(allowedKey, value); + + // Assert + Assert.AreEqual(1, backgroundData.Parameters.Count); + KeyValuePair item = backgroundData.Parameters.First(); + Assert.AreEqual(allowedKey, item.Key); + Assert.AreEqual(value, item.Value); + } + + [Test] + public void Parameters_AddOtherThanAllowed_ThrowInvalidOperationException() + { + // Setup + var backgroundData = new BackgroundData(); + + // Precondition + CollectionAssert.IsEmpty(backgroundData.Parameters); + + // Call + TestDelegate test = () => backgroundData.Parameters.Add("invalid key", "test"); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Key 'invalid key' is not allowed to add to the dictionary.", exception.Message); + CollectionAssert.IsEmpty(backgroundData.Parameters); + } + + [Test] + public void Parameters_AddOtherThanAllowed_ThrowInvalidOperationExceptions() + { + // Setup + var backgroundData = new BackgroundData(); + + // Precondition + CollectionAssert.IsEmpty(backgroundData.Parameters); + + // Call + TestDelegate test = () => backgroundData.Parameters["invalid key"] = "test"; + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Key 'invalid key' is not allowed to add to the dictionary.", exception.Message); + CollectionAssert.IsEmpty(backgroundData.Parameters); + } } } \ No newline at end of file