private static void AddWellKnownTileSourceMetaEntities(WellKnownBackgroundDataConfiguration wellKnownConfiguration, BackgroundDataEntity entity) { entity.BackgroundDataMetaEntities.Add(new BackgroundDataMetaEntity { Key = BackgroundDataIdentifiers.WellKnownTileSource.DeepClone(), Value = ((int)wellKnownConfiguration.WellKnownTileSource).ToString() }); }
public void DefaultConstructor_Always_ReturnsExpectedProperties() { // Setup var random = new Random(21); var wellKnownTileSource = random.NextEnumValue <RiskeerWellKnownTileSource>(); // Call var configuration = new WellKnownBackgroundDataConfiguration(wellKnownTileSource); // Assert Assert.IsInstanceOf <IBackgroundDataConfiguration>(configuration); Assert.AreEqual(wellKnownTileSource, configuration.WellKnownTileSource); }
public void Create_BackgroundDataContainsWellKnownConfiguration_ReturnsBackgroundDataEntity() { // Setup var random = new Random(21); var wellKnownTileSource = random.NextEnumValue <RiskeerWellKnownTileSource>(); const string name = "background"; const bool isVisible = true; const BackgroundDataType backgroundDataType = BackgroundDataType.WellKnown; var transparancy = (RoundedDouble)0.3; var configuration = new WellKnownBackgroundDataConfiguration(wellKnownTileSource); 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); Assert.AreEqual(Convert.ToByte(backgroundDataType), entity.BackgroundDataType); var expectedKeyValuePairs = new Dictionary <string, string> { { BackgroundDataIdentifiers.WellKnownTileSource, ((int)wellKnownTileSource).ToString() } }; IEnumerable <KeyValuePair <string, string> > actualKeyValuePairs = entity.BackgroundDataMetaEntities.Select( metaEntity => new KeyValuePair <string, string>(metaEntity.Key, metaEntity.Value)); CollectionAssert.AreEquivalent(expectedKeyValuePairs, actualKeyValuePairs); }
private static void AssertWellKnownBackgroundConfiguration(WellKnownBackgroundDataConfiguration wellKnownBackgroundDataConfiguration, WellKnownBackgroundDataConfiguration actualWellKnownBackgroundDataConfiguration) { Assert.AreEqual(wellKnownBackgroundDataConfiguration.WellKnownTileSource, actualWellKnownBackgroundDataConfiguration.WellKnownTileSource); }
/// <summary> /// Creates a <see cref="WellKnownTileSourceMapData"/>, based upon the /// properties of <paramref name="backgroundDataConfiguration"/>. /// </summary> /// <param name="backgroundDataConfiguration">The <see cref="BackgroundData"/> /// to base the <see cref="WellKnownTileSourceMapData"/> upon.</param> /// <returns>The newly created <see cref="WellKnownTileSourceMapData"/>.</returns> /// <exception cref="InvalidEnumArgumentException">Thrown when /// <see cref="WellKnownBackgroundDataConfiguration.WellKnownTileSource"/> /// contains an invalid value for <see cref="WellKnownTileSource"/>.</exception> private static WellKnownTileSourceMapData CreateWellKnownMapdata(WellKnownBackgroundDataConfiguration backgroundDataConfiguration) { return(new WellKnownTileSourceMapData((WellKnownTileSource)backgroundDataConfiguration.WellKnownTileSource)); }