public void ToIntTest() { const string SAMPLE_STRING = "fortythree"; const string SAMPLE_NUMBER = "45"; Assert.IsTrue(SmartConvert.ToInt(SAMPLE_NUMBER) == 45); Assert.IsFalse(SmartConvert.ToInt(SAMPLE_STRING) == 45); }
public void ToIntTest_WithInvalidObject() { var actual = SmartConvert.ToInt("55.44.45"); Assert.AreEqual(0, actual); actual = SmartConvert.ToInt("test 55.45.89"); Assert.AreEqual(0, actual); }
public void ToIntTest_WithMoreThanInteger() { var actual = SmartConvert.ToInt("559999999999999.458989894679"); Assert.AreEqual(0, actual); actual = SmartConvert.ToInt("-5599999999999999.458989894679"); Assert.AreEqual(0, actual); }
public void ToIntTest_WithNullsAndEmpties() { var actual = SmartConvert.ToInt(null); Assert.AreEqual(0, actual); actual = SmartConvert.ToInt(DBNull.Value); Assert.AreEqual(0, actual); actual = SmartConvert.ToInt(string.Empty); Assert.AreEqual(0, actual); }
public void ToIntTest_WithFloats() { var actual = SmartConvert.ToInt(55.4699); Assert.AreEqual(actual, 55); actual = SmartConvert.ToInt(55.6699); Assert.AreEqual(actual, 56); actual = SmartConvert.ToInt("55.6699"); Assert.AreEqual(actual, 56); }
public IList <MemberDiagnosisDto> GetMemberDiagnosis(int memberId) { var resultSet = new List <MemberDiagnosisDto>(); using (connection) { using (IDbCommand cmd = new SqlCommand(GET_MEMBER_DIAGNOSIS_AND_SEVERITY_COMMAND)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = connection; cmd.Parameters.Add(new SqlParameter("@MemberId", memberId)); try { connection.Open(); var reader = cmd.ExecuteReader(); while (reader.Read()) { var diagnosis = new MemberDiagnosisDto { MemberId = SmartConvert.ToInt(reader["MemberID"]), FirstName = reader["FirstName"].ToString(), LastName = reader["LastName"].ToString(), MostSevereDiagnosisId = SmartConvert.ToNullableInt(reader["MostSevereDiagnosisID"]), MostSevereDiagnosisDescription = reader["MostSevereDiagnosisDescription"].ToString(), DiagnosisCategoryId = SmartConvert.ToInt(reader["CategoryID"]), DiagnosisCategoryDescription = reader["CategoryDescription"].ToString(), DiagnosisCategoryScore = SmartConvert.ToInt(reader["CategoryScore"]), IsMostSevere = SmartConvert.ToBool(reader["IsMostSevere"]) }; resultSet.Add(diagnosis); } } catch (Exception ex) { connection.Close(); throw; } } } return(resultSet); }