Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/BackgroundDataCreateExtensions.cs =================================================================== diff -u -r7f540fc512a6c291d69612b1d0b9241d42288aef -r8f2d3db3a37f2f2d112e947c5d4b8928f05c559c --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/BackgroundDataCreateExtensions.cs (.../BackgroundDataCreateExtensions.cs) (revision 7f540fc512a6c291d69612b1d0b9241d42288aef) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/BackgroundDataCreateExtensions.cs (.../BackgroundDataCreateExtensions.cs) (revision 8f2d3db3a37f2f2d112e947c5d4b8928f05c559c) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using System.Collections.Generic; using Application.Ringtoets.Storage.DbContext; using Core.Common.Utils.Extensions; using Ringtoets.Common.Data.AssessmentSection; @@ -63,71 +62,53 @@ var wmtsBackgroundDataConfiguration = backgroundData.Configuration as WmtsBackgroundDataConfiguration; var wellKnownBackgroundDataConfiguration = backgroundData.Configuration as WellKnownBackgroundDataConfiguration; - var metaEntities = new List(); if (wmtsBackgroundDataConfiguration != null) { entity.BackgroundDataType = Convert.ToByte(BackgroundMapDataType.Wmts); - metaEntities.AddRange(GetWmtsMetaEntities(wmtsBackgroundDataConfiguration)); + AddWmtsMetaEntities(wmtsBackgroundDataConfiguration, entity); } else if (wellKnownBackgroundDataConfiguration != null) { entity.BackgroundDataType = Convert.ToByte(BackgroundMapDataType.WellKnown); - metaEntities.AddRange(GetWellKnownTileSourceMetaEntities(wellKnownBackgroundDataConfiguration)); + AddWellKnownTileSourceMetaEntities(wellKnownBackgroundDataConfiguration, entity); } - - foreach (BackgroundDataMetaEntity backgroundDataMetaEntity in metaEntities) - { - entity.BackgroundDataMetaEntities.Add(backgroundDataMetaEntity); - } } - private static IEnumerable GetWellKnownTileSourceMetaEntities(WellKnownBackgroundDataConfiguration wellKnownConfiguration) + private static void AddWellKnownTileSourceMetaEntities(WellKnownBackgroundDataConfiguration wellKnownConfiguration, BackgroundDataEntity entity) { - return new[] + entity.BackgroundDataMetaEntities.Add(new BackgroundDataMetaEntity { - new BackgroundDataMetaEntity - { - Key = BackgroundDataIdentifiers.WellKnownTileSource.DeepClone(), - Value = ((int) wellKnownConfiguration.WellKnownTileSource).ToString().DeepClone() - } - }; + Key = BackgroundDataIdentifiers.WellKnownTileSource.DeepClone(), + Value = ((int) wellKnownConfiguration.WellKnownTileSource).ToString().DeepClone() + }); } - private static IEnumerable GetWmtsMetaEntities(WmtsBackgroundDataConfiguration wmtsBackgroundDataConfiguration) + private static void AddWmtsMetaEntities(WmtsBackgroundDataConfiguration wmtsBackgroundDataConfiguration, BackgroundDataEntity entity) { - var entities = new List + entity.BackgroundDataMetaEntities.Add(new BackgroundDataMetaEntity { - new BackgroundDataMetaEntity - { - Key = BackgroundDataIdentifiers.IsConfigured, - Value = Convert.ToByte(wmtsBackgroundDataConfiguration.IsConfigured).ToString() - } - }; + Key = BackgroundDataIdentifiers.IsConfigured, + Value = Convert.ToByte(wmtsBackgroundDataConfiguration.IsConfigured).ToString() + }); if (wmtsBackgroundDataConfiguration.IsConfigured) { - entities.AddRange( - new[] - { - new BackgroundDataMetaEntity - { - Key = BackgroundDataIdentifiers.SelectedCapabilityIdentifier.DeepClone(), - Value = wmtsBackgroundDataConfiguration.SelectedCapabilityIdentifier.DeepClone() - }, - new BackgroundDataMetaEntity - { - Key = BackgroundDataIdentifiers.SourceCapabilitiesUrl.DeepClone(), - Value = wmtsBackgroundDataConfiguration.SourceCapabilitiesUrl.DeepClone() - }, - new BackgroundDataMetaEntity - { - Key = BackgroundDataIdentifiers.PreferredFormat.DeepClone(), - Value = wmtsBackgroundDataConfiguration.PreferredFormat.DeepClone() - } - }); + entity.BackgroundDataMetaEntities.Add(new BackgroundDataMetaEntity + { + Key = BackgroundDataIdentifiers.SelectedCapabilityIdentifier.DeepClone(), + Value = wmtsBackgroundDataConfiguration.SelectedCapabilityIdentifier.DeepClone() + }); + entity.BackgroundDataMetaEntities.Add(new BackgroundDataMetaEntity + { + Key = BackgroundDataIdentifiers.SourceCapabilitiesUrl.DeepClone(), + Value = wmtsBackgroundDataConfiguration.SourceCapabilitiesUrl.DeepClone() + }); + entity.BackgroundDataMetaEntities.Add(new BackgroundDataMetaEntity + { + Key = BackgroundDataIdentifiers.PreferredFormat.DeepClone(), + Value = wmtsBackgroundDataConfiguration.PreferredFormat.DeepClone() + }); } - - return entities; } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/BackgroundDataPropertiesTest.cs =================================================================== diff -u -rfa68b38773452b965a9ee25db20436446c1a50b8 -r8f2d3db3a37f2f2d112e947c5d4b8928f05c559c --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/BackgroundDataPropertiesTest.cs (.../BackgroundDataPropertiesTest.cs) (revision fa68b38773452b965a9ee25db20436446c1a50b8) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/BackgroundDataPropertiesTest.cs (.../BackgroundDataPropertiesTest.cs) (revision 8f2d3db3a37f2f2d112e947c5d4b8928f05c559c) @@ -61,19 +61,14 @@ public void Constructor_ValidBackgroundData_ExpectedValues() { // Setup - var mocks = new MockRepository(); - var configuration = mocks.Stub(); - mocks.ReplayAll(); + var backgroundMapData = new BackgroundData(new TestBackgroundDataConfiguration()); - var backgroundMapData = new BackgroundData(configuration); - // Call var properties = new BackgroundDataProperties(backgroundMapData); // Assert Assert.IsInstanceOf>(properties); Assert.AreSame(backgroundMapData, properties.Data); - mocks.VerifyAll(); } [Test] @@ -162,11 +157,10 @@ var mockRepository = new MockRepository(); var observer = mockRepository.StrictMock(); - var backgroundDataConfiguration = mockRepository.Stub(); observer.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); mockRepository.ReplayAll(); - var backgroundMapData = new BackgroundData(backgroundDataConfiguration); + var backgroundMapData = new BackgroundData(new TestBackgroundDataConfiguration()); backgroundMapData.Attach(observer); var properties = new BackgroundDataProperties(backgroundMapData); @@ -190,12 +184,8 @@ public void Constructor_WithNonWmtsMapDataConfiguration_PropertiesHaveExpectedAttributesValues() { // Setup - var mocks = new MockRepository(); - var backgroundDataConfiguration = mocks.Stub(); - mocks.ReplayAll(); + var backgroundMapData = new BackgroundData(new TestBackgroundDataConfiguration()); - var backgroundMapData = new BackgroundData(backgroundDataConfiguration); - // Call var properties = new BackgroundDataProperties(backgroundMapData); @@ -221,8 +211,6 @@ "Algemeen", "Weergeven", "Geeft aan of de geselecteerde achtergrond kaartlaag in alle kaarten van dit traject wordt weergegeven."); - - mocks.VerifyAll(); } [Test] Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs =================================================================== diff -u -rfa68b38773452b965a9ee25db20436446c1a50b8 -r8f2d3db3a37f2f2d112e947c5d4b8928f05c559c --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs (.../BackgroundDataTreeNodeInfoTest.cs) (revision fa68b38773452b965a9ee25db20436446c1a50b8) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs (.../BackgroundDataTreeNodeInfoTest.cs) (revision 8f2d3db3a37f2f2d112e947c5d4b8928f05c559c) @@ -163,7 +163,7 @@ // Setup var random = new Random(21); var wellKnownTileSource = random.NextEnumValue(); - var backgroundMapData = BackgroundDataTestDataGenerator.GetWellKnownBackgroundMapData(wellKnownTileSource); + BackgroundData backgroundMapData = BackgroundDataTestDataGenerator.GetWellKnownBackgroundMapData(wellKnownTileSource); using (var plugin = new RingtoetsPlugin()) { @@ -181,12 +181,8 @@ public void ForeColor_ArbitraryBackgroundDataConfiguration_ReturnControlText() { // Setup - var mockRepository = new MockRepository(); - var configuration = mockRepository.Stub(); - mockRepository.ReplayAll(); + var backgroundMapData = new BackgroundData(new TestBackgroundDataConfiguration()); - var backgroundMapData = new BackgroundData(configuration); - using (var plugin = new RingtoetsPlugin()) { TreeNodeInfo info = GetInfo(plugin); @@ -238,11 +234,9 @@ public void ContextMenuStrip_Always_ContextMenuItemSelectMapLayerEnabled() { // Setup - var mockRepository = new MockRepository(); - var configuration = mockRepository.Stub(); + var backgroundMapData = new BackgroundData(new TestBackgroundDataConfiguration()); - var backgroundMapData = new BackgroundData(configuration); - + var mockRepository = new MockRepository(); var assessmentSection = mockRepository.Stub(); using (var treeViewControl = new TreeViewControl()) {