public void GetUserItemsTest() { CarRepairDAO dao = new CarRepairDAO(ConnectionString); //delete entire table dao.DeleteAllVehicles(); dao.DeleteAllUsers(); //create new users User user = CreateFirstTestUser(); int newUserID = dao.AddUser(user); User user2 = CreateSecondTestUser(); int newUser2ID = dao.AddUser(user2); List <User> userList = new List <User>(); userList = dao.GetUserItems(); Assert.AreEqual(userList.Count, 2, "2 users were not returned"); Assert.AreEqual(userList[0].Id, newUserID, "First user's ID does not match first user in list"); Assert.AreEqual(userList[1].Id, newUser2ID, "Second user's ID does not match second user in list"); }
public void GetIncidentsTest() { CarRepairDAO dao = new CarRepairDAO(ConnectionString); dao.DeleteAllIncidents(); User user = CreateFirstTestUser(); int userId = dao.AddUser(user); Vehicle vehicle = CreateTestVehicle(userId); int vehicleId = dao.AddVehicleItems(vehicle); Incident incident1 = CreateFirstTestIncident(vehicleId); int newIncidentID = dao.AddIncident(incident1); Incident incident2 = CreateSecondTestIncident(vehicleId); int newIncidentID2 = dao.AddIncident(incident2); List <Incident> incidentList = new List <Incident>(); incidentList = dao.GetIncidents(); Assert.AreEqual(incidentList.Count, 2, "2 users were not returned"); Assert.AreEqual(incidentList[0].Id, newIncidentID, "First user's ID does not match first user in list"); Assert.AreEqual(incidentList[1].Id, newIncidentID2, "Second user's ID does not match second user in list"); }
public void AddIncidentTest() { CarRepairDAO dao = new CarRepairDAO(ConnectionString); //add user User user = CreateFirstTestUser(); int userId = dao.AddUser(user); //add vehicle and set incident to that id Vehicle vehicle = CreateTestVehicle(userId); int vehicleId = dao.AddVehicleItems(vehicle); Incident incident = CreateFirstTestIncident(vehicleId); int newId = dao.AddIncident(incident); var newUser = dao.GetIncidentById(newId); Assert.AreEqual(newId, newUser.Id, "ID does not match, check GetIncidentById Method"); Assert.AreEqual(incident.VehicleId, newUser.VehicleId, "Vehicle ID does not match"); Assert.AreEqual(incident.Description, newUser.Description, "Description does not match"); Assert.AreEqual(incident.SubmittedDate, newUser.SubmittedDate, "SubmittedDate does not match"); Assert.AreEqual(incident.Paid, newUser.Paid, "Paid bool does not match"); }
public void GetIncidentsByUserTest() { CarRepairDAO dao = new CarRepairDAO(ConnectionString); List <Incident> incidentsList = new List <Incident>(); //delete all vehicles dao.DeleteAllVehicles(); //delete users dao.DeleteAllUsers(); //delete incidents dao.DeleteAllIncidents(); //delete all vehicles dao.DeleteAllVehicles(); //add user and return id User user = CreateFirstTestUser(); int newUserID = dao.AddUser(user); //add vehicle Vehicle vehicle = CreateTestVehicle(newUserID); int vehicleId = dao.AddVehicleItems(vehicle); //add incidents with new user id Incident incident1 = CreateFirstTestIncident(vehicleId); int newIncidentID = dao.AddIncident(incident1); Incident incident2 = CreateSecondTestIncident(vehicleId); int newIncidentID2 = dao.AddIncident(incident2); //call get method and add to incidents list incidentsList = dao.GetIncidentsByUser(newUserID); Assert.AreEqual(incidentsList.Count, 2, "2 incidents were not returned"); Assert.AreEqual(incidentsList[0].VehicleId, vehicleId, "First incidents vehicle ID does not match"); Assert.AreEqual(incidentsList[1].VehicleId, vehicleId, "Second incidents vehicle ID does not match"); }
public void AddUserTest() { //// Arrange CarRepairDAO dao = new CarRepairDAO(ConnectionString); User user = CreateFirstTestUser(); int newId = dao.AddUser(user); var newUser = dao.GetUserById(newId); Assert.AreEqual(newId, newUser.Id, "ID does not match, check GetUserItemByIdMethod"); Assert.AreEqual(user.RoleId, newUser.RoleId, "Role ID does not match"); Assert.AreEqual(user.Username, newUser.Username, "UserName does not match"); Assert.AreEqual(user.FirstName, newUser.FirstName, "FirstName does not match"); Assert.AreEqual(user.LastName, newUser.LastName, "LastName does not match"); Assert.AreEqual(user.Email, newUser.Email, "Email does not match"); Assert.AreEqual(user.PhoneNumber, newUser.PhoneNumber, "PhoneNumber does not match"); Assert.AreEqual(user.Hash, newUser.Hash, "Hash does not match"); Assert.AreEqual(user.Salt, newUser.Salt, "Salt does not match"); }