public void CastTo_Double_1a() { var res = ValueUtilities.CastTo($"3{GetDecimalSeparator()}14", typeof(double)); Assert.IsInstanceOfType(res, typeof(double)); Assert.AreEqual(3.14, res); }
/// <summary> /// Creates a list of the specified element type and fills in the elements into the list. /// </summary> /// <param name="elementType">The element type of the list.</param> /// <returns>The list.</returns> private IList CreateList(Type elementType) { var genericType = typeof(List <>).MakeGenericType(elementType); var list = (IList)Activator.CreateInstance(genericType); foreach (var instanceProvider in _instanceProviders) { var instance = instanceProvider.GetInstance(); var castedInstance = ValueUtilities.CastTo(instance, elementType); list.Add(castedInstance); } return(list); }
public void CastTo_Double_1b() { var res = ValueUtilities.CastTo <double>($"3{GetDecimalSeparator()}14"); Assert.AreEqual(3.14, res); }