public void WhenAllPartsOfTheListAreInvalid_ShouldReturnNull(string invalidList) { //Arange //Act IList <int> result = _apiTypeConverter.ToListOfInts(invalidList); //Assert Assert.IsNull(result); }
private object To(string value, Type type) { if (type == typeof(DateTime?)) { return(_apiTypeConverter.ToUtcDateTimeNullable(value)); } else if (type == typeof(int?)) { return(_apiTypeConverter.ToIntNullable(value)); } else if (type == typeof(int)) { return(_apiTypeConverter.ToInt(value)); } else if (type == typeof(List <int>)) { return(_apiTypeConverter.ToListOfInts(value)); } else if (type == typeof(List <string>)) { return(_apiTypeConverter.ToListOfStrings(value)); } else if (type == typeof(bool?)) { // Because currently status is the only boolean and we need to accept published and unpublished statuses. return(_apiTypeConverter.ToStatus(value)); } else if (IsNullableEnum(type)) { return(_apiTypeConverter.ToEnumNullable(value, type)); } // It should be the last resort, because it is not exception safe. return(Convert.ChangeType(value, type)); }
private object To(string value, Type type) { if (type == typeof(DateTime?)) { return(_apiTypeConverter.ToUtcDateTimeNullable(value)); } if (type == typeof(int?)) { return(_apiTypeConverter.ToIntNullable(value)); } if (type == typeof(int)) { return(_apiTypeConverter.ToInt(value)); } if (type == typeof(List <int>)) { return(_apiTypeConverter.ToListOfInts(value)); } if (type == typeof(List <string>)) { return(_apiTypeConverter.ToListOfStrings(value)); } if (IsNullableEnum(type)) { return(_apiTypeConverter.ToEnumNullable(value, type)); } // It should be the last resort, because it is not exception safe. return(Convert.ChangeType(value, type)); }
public void Should_return_null_when_all_parts_of_list_invalid(string invalidList) { var result = _apiTypeConverter.ToListOfInts(invalidList); result.ShouldBeNull(); }