public void WhenInvalidStatusPassed_ShouldReturnNull(string invalidStatus) { //Arange //Act bool?result = _apiTypeConverter.ToStatus(invalidStatus); //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)); }
public void Should_return_null_when_invalid_status_passed(string invalidStatus) { bool?result = _apiTypeConverter.ToStatus(invalidStatus); Assert.IsNull(result); }