Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/BackgroundMapDataSelectionDialogTest.cs =================================================================== diff -u -r38abc823a892327c367dfbf8edf2101ff3eb1d22 -rdc229a7f477b15ac8d52a9164451b21202891772 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/BackgroundMapDataSelectionDialogTest.cs (.../BackgroundMapDataSelectionDialogTest.cs) (revision 38abc823a892327c367dfbf8edf2101ff3eb1d22) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/BackgroundMapDataSelectionDialogTest.cs (.../BackgroundMapDataSelectionDialogTest.cs) (revision dc229a7f477b15ac8d52a9164451b21202891772) @@ -22,11 +22,15 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Linq; using System.Threading; using System.Windows.Forms; +using BruTile; using Core.Common.Controls.Dialogs; using Core.Common.TestUtil; using Core.Components.DotSpatial.Forms.Views; +using Core.Components.DotSpatial.Layer.BruTile.Configurations; +using Core.Components.DotSpatial.TestUtil; using Core.Components.Gis.Data; using NUnit.Extensions.Forms; using NUnit.Framework; @@ -38,10 +42,28 @@ [TestFixture] public class BackgroundMapDataSelectionDialogTest : NUnitFormTest { + private MockRepository mockRepository; + private ITileSourceFactory tileFactory; + + [SetUp] + public void SetUp() + { + mockRepository = new MockRepository(); + tileFactory = mockRepository.StrictMock(); + } + + [TearDown] + public override void TearDown() + { + mockRepository.VerifyAll(); + base.TearDown(); + } + [Test] public void Constructor_WithoutParent_ThrowsArgumentNullException() { // Setup + mockRepository.ReplayAll(); WmtsMapData mapData = WmtsMapData.CreateDefaultPdokMapData(); // Call @@ -53,39 +75,9 @@ } [Test] - public void Constructor_WithValidArguments_DefaultProperties() - { - // Setup - WmtsMapData mapData = WmtsMapData.CreateDefaultPdokMapData(); - using (var dialogParent = new Form()) - { - // Call - using (var dialog = new BackgroundMapDataSelectionDialog(dialogParent, mapData)) - { - // Assert - Assert.IsInstanceOf(dialog); - Assert.AreEqual(@"Selecteer achtergrondkaart", dialog.Text); - Assert.AreSame(mapData, dialog.SelectedMapData); - - Icon icon = BitmapToIcon(RingtoetsCommonFormsResources.SelectionDialogIcon); - Bitmap expectedImage = icon.ToBitmap(); - Bitmap actualImage = dialog.Icon.ToBitmap(); - TestHelper.AssertImagesAreEqual(expectedImage, actualImage); - - var mapLayers = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject; - Assert.AreEqual(ComboBoxStyle.DropDownList, mapLayers.DropDownStyle); - Assert.IsInstanceOf>(mapLayers.DataSource); - Assert.AreEqual("DisplayName", mapLayers.DisplayMember); - Assert.IsTrue(mapLayers.Sorted); - } - } - } - - [Test] public void Constructor_MapDataNull_DefaultProperties() { // Setup - var mockRepository = new MockRepository(); var dialogParent = mockRepository.Stub(); mockRepository.ReplayAll(); @@ -95,13 +87,13 @@ // Assert Assert.IsNull(dialog.SelectedMapData); } - mockRepository.VerifyAll(); } [Test] public void MapDataConstructor_ParentNull_ThrowsArgumentNullException() { // Setup + mockRepository.ReplayAll(); WmtsMapData mapData = WmtsMapData.CreateDefaultPdokMapData(); // Call @@ -117,6 +109,10 @@ { // Setup WmtsMapData mapData = WmtsMapData.CreateDefaultPdokMapData(); + tileFactory.Expect(tf => tf.GetWmtsTileSources(mapData.SourceCapabilitiesUrl)).Return(Enumerable.Empty()); + mockRepository.ReplayAll(); + + using (new UseCustomTileSourceFactoryConfig(tileFactory)) using (var dialogParent = new Form()) { // Call @@ -146,6 +142,7 @@ public void ShowDialog_Always_DefaultProperties() { // Setup + mockRepository.ReplayAll(); DialogBoxHandler = (name, wnd) => { using (new FormTester(name)) {} @@ -184,6 +181,7 @@ public void GivenValidDialog_WhenCancelPressed_ThenSelectedMapDataNull() { // Given + mockRepository.ReplayAll(); Button cancelButton = null; DialogBoxHandler = (name, wnd) => @@ -211,6 +209,9 @@ [Test] public void Dispose_DisposedAlreadyCalled_DoesNotThrowException() { + // Setup + mockRepository.ReplayAll(); + // Call TestDelegate call = () => {