Пример #1
0
        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");
        }
Пример #2
0
        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");
        }
Пример #3
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");
        }