public void TestConnect() { //arrange bool expect = true; bool actual = true; IDatabaseAccess target = new SqlClientDataAccess(this._ConnectionString); //act target.OpenConnection(); target.CloseConnection(); //assert Assert.AreEqual(expect, actual); }
public void TestQueryDataReaderWithParameter() { //arrange bool expect = true; bool actual = true; IDatabaseAccess target = new SqlClientDataAccess(this._ConnectionString); IDataReader result; DataAccessCommand command = new DataAccessCommand(); List<Department> employeeCollection; //act command.SqlCommand = @"SELECT DOMAINNAME, NAME, FULLNAME FROM v_VoyageRptDepartment WHERE DOMAINNAME=@DOMAIN"; command.AddParameter("DOMAIN", "Evaair"); try { result = target.QueryWithDataReader(command); employeeCollection = new List<Department>(); while (result.Read()) { employeeCollection.Add( new Department( result.GetString(result.GetOrdinal("DOMAINNAME")), result.GetString(result.GetOrdinal("FULLNAME")), result.GetString(result.GetOrdinal("NAME"))) ); } actual = (employeeCollection.Count > 0); } catch (Exception) { throw; } finally { target.CloseConnection(); } //assert Assert.AreEqual(expect, actual); }