public void CanClone() { string parameterName = "p1Name"; const string stringValueInvariant = "0.123"; Type dataType = typeof(double); var testParameterValue = new ScalarTestParameterValue(parameterName, dataType); testParameterValue.SetStringValue(0.123d.ToString(CultureInfo.CurrentCulture)); ScalarTestParameterValue clone = (ScalarTestParameterValue)testParameterValue.Clone(); Assert.IsTrue(testParameterValue.Equals(clone)); Assert.IsTrue(testParameterValue.DataType == clone.DataType); Assert.AreEqual(parameterName, clone.TestParameterName); Assert.AreEqual(dataType, clone.DataType); Assert.AreEqual(stringValueInvariant, clone.StringValue); }
private static void EnsureDisplayValue(Type dataType, string stringValueCurrentCulture) { const string parameterName = "Test"; var testParameterValue = new ScalarTestParameterValue(parameterName, dataType); testParameterValue.SetStringValue(stringValueCurrentCulture); string valueWithKnownDatatype = testParameterValue.GetDisplayValue(); Assert.AreEqual(stringValueCurrentCulture, valueWithKnownDatatype); object value = testParameterValue.GetValue(); Assert.NotNull(value); string persistedValue = testParameterValue.PersistedStringValue; testParameterValue.DataType = null; string valueWithGuessedDatatype = testParameterValue.GetDisplayValue(); Assert.AreEqual(stringValueCurrentCulture, valueWithGuessedDatatype); // Now set the same value using InvariantCulture and try again: testParameterValue = new ScalarTestParameterValue(parameterName, dataType); testParameterValue.SetStringValue(persistedValue, CultureInfo.InvariantCulture); valueWithKnownDatatype = testParameterValue.GetDisplayValue(); Assert.AreEqual(stringValueCurrentCulture, valueWithKnownDatatype); testParameterValue.DataType = null; valueWithGuessedDatatype = testParameterValue.GetDisplayValue(); Assert.AreEqual(stringValueCurrentCulture, valueWithGuessedDatatype); }