public void HasSameConfiguration_ForDifferentInitializedLayer_ReturnFalse(WmtsMapData otherData)
        {
            // Setup
            var mocks       = new MockRepository();
            var tileFetcher = mocks.Stub <ITileFetcher>();

            using (var layerStatus = new WmtsBackgroundLayerStatus())
            {
                IConfiguration configuration = CreateStubConfiguration(mocks, tileFetcher);
                mocks.ReplayAll();

                using (var layer = new BruTileLayer(configuration))
                {
                    WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

                    layerStatus.LayerInitializationSuccessful(layer, mapData);

                    // Call
                    bool isSame = layerStatus.HasSameConfiguration(otherData);

                    // Assert
                    Assert.IsFalse(isSame);
                }
            }

            mocks.VerifyAll();
        }
        public void HasSameConfiguration_ForInitializedLayer_ReturnTrue()
        {
            // Setup
            var mocks       = new MockRepository();
            var tileFetcher = mocks.Stub <ITileFetcher>();

            using (var layerStatus = new WmtsBackgroundLayerStatus())
            {
                IConfiguration configuration = CreateStubConfiguration(mocks, tileFetcher);
                mocks.ReplayAll();

                using (var layer = new BruTileLayer(configuration))
                {
                    WmtsMapData mapData1 = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
                    WmtsMapData mapData2 = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

                    layerStatus.LayerInitializationSuccessful(layer, mapData1);

                    // Call
                    bool isSame = layerStatus.HasSameConfiguration(mapData2);

                    // Assert
                    Assert.IsTrue(isSame,
                                  "Should recognize same configuration even if instance is not the same.");
                }
            }

            mocks.VerifyAll();
        }
        public void HasSameConfiguration_NoInitializedLayer_ReturnFalse()
        {
            // Setup
            using (var layerStatus = new WmtsBackgroundLayerStatus())
            {
                WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();

                // Call
                bool isSame = layerStatus.HasSameConfiguration(mapData);

                // Assert
                Assert.IsFalse(isSame);
            }
        }
        public void HasSameConfiguration_MapDataNotWmtsMapData_ReturnFalse()
        {
            // Setup
            using (var layerStatus = new WmtsBackgroundLayerStatus())
            {
                var mapData = new SimpleImageBasedMapData();

                // Call
                bool isSame = layerStatus.HasSameConfiguration(mapData);

                // Assert
                Assert.IsFalse(isSame);
            }
        }
        public void ClearConfiguration_WithFailedLayerInitializationAndExpectingRecreation_ConfigurationClearedButKeepFailedFlagSet()
        {
            // Setup
            using (var layerStatus = new WmtsBackgroundLayerStatus())
            {
                WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
                layerStatus.LayerInitializationFailed();

                // Call
                layerStatus.ClearConfiguration(true);

                // Assert
                Assert.IsTrue(layerStatus.PreviousBackgroundLayerCreationFailed);
                Assert.IsFalse(layerStatus.HasSameConfiguration(mapData));
            }
        }
        public void ClearConfiguration_HasLayer_ConfigurationCleared()
        {
            // Setup
            var            mocks         = new MockRepository();
            var            tileFetcher   = mocks.Stub <ITileFetcher>();
            IConfiguration configuration = CreateStubConfiguration(mocks, tileFetcher);

            mocks.ReplayAll();

            using (var layer = new BruTileLayer(configuration))
                using (var layerStatus = new WmtsBackgroundLayerStatus())
                {
                    WmtsMapData mapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
                    layerStatus.LayerInitializationSuccessful(layer, mapData);

                    // Call
                    layerStatus.ClearConfiguration();

                    // Assert
                    Assert.IsFalse(layerStatus.PreviousBackgroundLayerCreationFailed);
                    Assert.IsFalse(layerStatus.HasSameConfiguration(mapData));
                }
        }