private static void AddWmtsMetaEntities(WmtsBackgroundDataConfiguration wmtsBackgroundDataConfiguration, BackgroundDataEntity entity)
        {
            entity.BackgroundDataMetaEntities.Add(new BackgroundDataMetaEntity
            {
                Key   = BackgroundDataIdentifiers.IsConfigured,
                Value = Convert.ToByte(wmtsBackgroundDataConfiguration.IsConfigured).ToString()
            });

            if (wmtsBackgroundDataConfiguration.IsConfigured)
            {
                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()
                });
            }
        }
Esempio n. 2
0
 private static void AssertWmtsBackgroundConfiguration(WmtsBackgroundDataConfiguration expectedWmtsBackgroundDataConfiguration,
                                                       WmtsBackgroundDataConfiguration actualWmtsBackgroundDataConfiguration)
 {
     Assert.AreEqual(expectedWmtsBackgroundDataConfiguration.IsConfigured, actualWmtsBackgroundDataConfiguration.IsConfigured);
     Assert.AreEqual(expectedWmtsBackgroundDataConfiguration.SourceCapabilitiesUrl, actualWmtsBackgroundDataConfiguration.SourceCapabilitiesUrl);
     Assert.AreEqual(expectedWmtsBackgroundDataConfiguration.SelectedCapabilityIdentifier, actualWmtsBackgroundDataConfiguration.SelectedCapabilityIdentifier);
     Assert.AreEqual(expectedWmtsBackgroundDataConfiguration.PreferredFormat, actualWmtsBackgroundDataConfiguration.PreferredFormat);
 }
Esempio n. 3
0
        private static WmtsMapData CreateWmtsMapData(string name, WmtsBackgroundDataConfiguration backgroundDataConfiguration)
        {
            if (backgroundDataConfiguration.IsConfigured)
            {
                return(new WmtsMapData(name,
                                       backgroundDataConfiguration.SourceCapabilitiesUrl,
                                       backgroundDataConfiguration.SelectedCapabilityIdentifier,
                                       backgroundDataConfiguration.PreferredFormat));
            }

            return(new WmtsMapData(name));
        }
        public void Create_BackgroundDataContainsConfiguredWMTSConfiguration_ReturnsBackgroundDataEntity()
        {
            // Setup
            const string name = "background";
            const string sourceCapabilitiesUrl  = "//url";
            const string selectedCapabilityName = "selectedName";
            const string preferredFormat        = "image/png";
            const bool   isVisible    = true;
            const bool   isConfigured = true;
            var          transparancy = (RoundedDouble)0.3;

            var configuration = new WmtsBackgroundDataConfiguration(isConfigured,
                                                                    sourceCapabilitiesUrl,
                                                                    selectedCapabilityName,
                                                                    preferredFormat);

            var backgroundData = new BackgroundData(configuration)
            {
                IsVisible    = isVisible,
                Transparency = transparancy,
                Name         = name
            };

            // Call
            BackgroundDataEntity entity = backgroundData.Create();

            // Assert
            Assert.AreEqual(name, entity.Name);
            Assert.AreEqual(Convert.ToByte(isVisible), entity.IsVisible);
            Assert.AreEqual(transparancy, entity.Transparency);

            var expectedKeyValuePairs = new Dictionary <string, string>
            {
                {
                    BackgroundDataIdentifiers.IsConfigured, Convert.ToByte(isConfigured).ToString()
                },
                {
                    BackgroundDataIdentifiers.SourceCapabilitiesUrl, sourceCapabilitiesUrl
                },
                {
                    BackgroundDataIdentifiers.SelectedCapabilityIdentifier, selectedCapabilityName
                },
                {
                    BackgroundDataIdentifiers.PreferredFormat, preferredFormat
                }
            };

            IEnumerable <KeyValuePair <string, string> > actualKeyValuePairs = entity.BackgroundDataMetaEntities.Select(
                metaEntity => new KeyValuePair <string, string>(metaEntity.Key, metaEntity.Value));

            CollectionAssert.AreEquivalent(expectedKeyValuePairs, actualKeyValuePairs);
        }
        public void DefaultConstructor_Always_ReturnsExpectedProperties()
        {
            // Call
            var configuration = new WmtsBackgroundDataConfiguration();

            // Assert
            Assert.IsInstanceOf <IBackgroundDataConfiguration>(configuration);

            Assert.IsFalse(configuration.IsConfigured);
            Assert.IsNull(configuration.SourceCapabilitiesUrl);
            Assert.IsNull(configuration.SelectedCapabilityIdentifier);
            Assert.IsNull(configuration.PreferredFormat);
        }
        public void ParameteredConstructor_IsConfiguredFalseAndValidParameters_ReturnsExpectedProperties()
        {
            // Call
            var configuration = new WmtsBackgroundDataConfiguration(false,
                                                                    null,
                                                                    null,
                                                                    null);

            // Assert
            Assert.IsInstanceOf <IBackgroundDataConfiguration>(configuration);

            Assert.IsFalse(configuration.IsConfigured);
            Assert.IsNull(configuration.SourceCapabilitiesUrl);
            Assert.IsNull(configuration.SelectedCapabilityIdentifier);
            Assert.IsNull(configuration.PreferredFormat);
        }
        public void ParameteredConstructor_IsConfiguredTrueAndValidParameters_ReturnsExpectedProperties(string sourceCapabilitiesUrl,
                                                                                                        string selectedCapabilityIdentifier,
                                                                                                        string preferredFormat)
        {
            // Call
            var configuration = new WmtsBackgroundDataConfiguration(true,
                                                                    sourceCapabilitiesUrl,
                                                                    selectedCapabilityIdentifier,
                                                                    preferredFormat);

            // Assert
            Assert.IsInstanceOf <IBackgroundDataConfiguration>(configuration);

            Assert.IsTrue(configuration.IsConfigured);
            Assert.AreEqual(sourceCapabilitiesUrl, configuration.SourceCapabilitiesUrl);
            Assert.AreEqual(selectedCapabilityIdentifier, configuration.SelectedCapabilityIdentifier);
            Assert.AreEqual(preferredFormat, configuration.PreferredFormat);
        }
        public void Create_BackgroundDataContainsUnconfiguredWMTSConfiguration_ReturnsBackgroundDataEntity()
        {
            // Setup
            const string name         = "background";
            const bool   isVisible    = true;
            const bool   isConfigured = false;
            var          transparancy = (RoundedDouble)0.3;

            var configuration = new WmtsBackgroundDataConfiguration();

            var backgroundData = new BackgroundData(configuration)
            {
                IsVisible    = isVisible,
                Transparency = transparancy,
                Name         = name
            };

            // Call
            BackgroundDataEntity entity = backgroundData.Create();

            // Assert
            Assert.AreEqual(name, entity.Name);
            Assert.AreEqual(Convert.ToByte(isVisible), entity.IsVisible);
            Assert.AreEqual(transparancy, entity.Transparency);

            var expectedKeyValuePairs = new Dictionary <string, string>
            {
                {
                    BackgroundDataIdentifiers.IsConfigured, Convert.ToByte(isConfigured).ToString()
                }
            };

            IEnumerable <KeyValuePair <string, string> > actualKeyValuePairs = entity.BackgroundDataMetaEntities.Select(
                metaEntity => new KeyValuePair <string, string>(metaEntity.Key, metaEntity.Value));

            CollectionAssert.AreEquivalent(expectedKeyValuePairs, actualKeyValuePairs);
        }