private static object FormatValueAsExpectedString(object value) { var valueType = value.GetType(); if (valueType == typeof(DateTime)) { return(DateTimeHelper.Serialize((DateTime)value)); } if (valueType == typeof(bool)) { return(BooleanHelper.Serialize((bool)value)); } if (valueType == typeof(double?)) { return(DoubleHelper.Serialize((double?)value)); } if (valueType == typeof(int?)) { return(IntHelper.Serialize((int?)value)); } return(value.ToString()); }
public void Serialize_DoubleHasValue_ReturnsExpectedString(Tuple <string, double> testCases) { var value = testCases.Item2; var expected = testCases.Item1; var result = DoubleHelper.Serialize(value); Assert.That(result, Is.EqualTo(expected)); }
public void Serialize_ValueIsNull_ReturnsEmptyString() { var result = DoubleHelper.Serialize(null); Assert.That(result, Is.Null); }