Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        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");
        }