Hi, for my project i have to do unit testing in visual studio. I'm using the baked in SQL server. How would i do this?
I've tried creating a unitTest project and then create an instance of of my SQLDataFunction class which includes all of the references to my SQL operations but it just takes forever when loading. I'm stuck, and don't know what to do.
How would i test something like this:
string query = " SELECT cs.coachScheduleId, cs.stationDeparture, cs.stationArrival, cs.timeOfDeparture, cs.timeOfArrival, cs.dateOfDeparture, c.numberOfSeats FROM coachSchedule cs JOIN Coach c ON cs.coachId = c.CoachId WHERE cs.dateOfDeparture BETWEEN @dateFrom AND @dateTo AND cs.stationDeparture= @travelFrom AND cs.stationArrival= @travelTo";
cmd = new SqlCommand(query, _IsqlDataFunctions.GetConnection());
cmd.Parameters.AddWithValue("@dateFrom", dateFromPicker.Value);
cmd.Parameters.AddWithValue("@dateTo", dateTooPicker.Value);
cmd.Parameters.AddWithValue("@travelFrom", comboBoxTravelFrom.SelectedValue);
cmd.Parameters.AddWithValue("@travelTo", comboBoxTravelTo.SelectedValue);
_IsqlDataFunctions.displayDataInGrid(cmd, availableBookings);
if (availableBookings.Rows.Count == 0)
{
MessageBox.Show("Unfortunately no bookings can be found with the information you have entered. Please try again.");
}