public void PersistInspectionTest() { InspectionDAO inspectionDAO = new InspectionDAOImp(new VehicleDAOImpl()); UserDAO userDAO = new UserDAOImp(); List <DamageDTO> damages = this.CreateDamages(); UserDTO user = this.CreateUser(); VehicleDTO vehicle = this.CreateVehicle(); InspectionDTO inspection = new InspectionDTO(); inspection.Damages = damages; inspection.CreatorUserName = user.UserName; inspection.Date = DateTime.Now; inspection.Location = "Puerto 1"; inspection.IdVehicle = vehicle.Vin; Guid id = inspectionDAO.AddInspection(inspection); InspectionDTO resultInspection = inspectionDAO.FindInspectionById(inspection.Id); Assert.AreEqual(inspection.CreatorUserName, resultInspection.CreatorUserName); Assert.AreEqual(inspection.Id, resultInspection.Id); Assert.AreEqual(inspection.Location, resultInspection.Location); foreach (DamageDTO damage in inspection.Damages) { Assert.IsNotNull(resultInspection.Damages.Find(d => d.Description == damage.Description)); } }
public Batch ToEntity(BatchDTO batchDTO) { UserDAO userDAO = new UserDAOImp(); List <Vehicle> vehicles = new List <Vehicle>(); foreach (var vin in batchDTO.Vehicles) { Vehicle vehicle = new Vehicle(); vehicle.Vin = vin; vehicles.Add(vehicle); } Batch batch = new Batch(); batch.Id = batchDTO.Id; User user = new User(); user.UserName = batchDTO.CreatorUserName; batch.IdUser = user; batch.Description = batchDTO.Description; batch.Name = batchDTO.Name; batch.Vehicles = vehicles; return(batch); }
private UserDTO CreateUser() { UserDTO user = new UserDTO(); user.Name = "Pepe"; user.LastName = "Lopez"; user.UserName = "******"; user.Password = "******"; user.Phone = 091234567; user.Role = Roles.ADMINISTRATOR.GetName(); UserDAO userDAO = new UserDAOImp(); userDAO.AddUser(user); return(user); }
private void CreateUser() { UserDTO expectedUser = new UserDTO(); expectedUser.Name = "Pepe"; expectedUser.LastName = "Lopez"; expectedUser.UserName = "******"; expectedUser.Password = "******"; expectedUser.Phone = 091234567; expectedUser.Role = "Administrador"; UserDAO userDAO = new UserDAOImp(); UserDTO userExist = userDAO.FindUserByUserName(expectedUser.UserName); if (userExist == null) { userDAO.AddUser(expectedUser); } }
public void ExistVehicleInspectionTest() { InspectionDAO inspectionDAO = new InspectionDAOImp(new VehicleDAOImpl()); UserDAO userDAO = new UserDAOImp(); List <DamageDTO> damages = this.CreateDamages(); UserDTO user = this.CreateUser(); VehicleDTO vehicle = this.CreateVehicle(); InspectionDTO inspection = new InspectionDTO(); inspection.Damages = damages; inspection.CreatorUserName = user.UserName; inspection.Date = DateTime.Now; inspection.Location = "Puerto 1"; inspection.IdVehicle = vehicle.Vin; Guid id = inspectionDAO.AddInspection(inspection); Assert.IsTrue(inspectionDAO.ExistVehicleInspection(vehicle.Vin)); }
public void PersistUserTest() { UserDTO expectedUser = new UserDTO(); expectedUser.Name = "Pepe"; expectedUser.LastName = "Lopez"; expectedUser.UserName = "******"; expectedUser.Password = "******"; expectedUser.Phone = 091234567; expectedUser.Role = "Administrador"; UserDAO userDAO = new UserDAOImp(); userDAO.AddUser(expectedUser); UserDTO resultUser = userDAO.FindUserByUserName("pepito123"); Assert.AreEqual(expectedUser.LastName, resultUser.LastName); Assert.AreEqual(expectedUser.Name, resultUser.Name); Assert.AreEqual(expectedUser.Phone, resultUser.Phone); Assert.AreEqual(expectedUser.Role, resultUser.Role); Assert.AreEqual(expectedUser.UserName, resultUser.UserName); }
public void LogInUserNotCorrectTest() { UserDTO user = new UserDTO(); user.Name = "Pepe"; user.LastName = "Lopez"; user.UserName = "******"; user.Password = "******"; user.Phone = 091234567; user.Role = "Administrador"; UserDAO userDAO = new UserDAOImp(); userDAO.AddUser(user); LoginDTO login = new LoginDTO(); login.UserName = "******"; login.Password = "******"; UserDTO userDTO = userDAO.LogIn(login); Assert.IsNull(userDTO); }