public void EvalTest4() { PositiveIntOrMinusOneValidator target = new PositiveIntOrMinusOneValidator(); string input = "10"; target.Eval(input); Assert.AreEqual(target.HasErrors, false); }
/// <summary> /// Checks parameters provided by the GUI and loads existing Projekte according to the provided values /// </summary> /// <returns>A list of all fitting Projekte</returns> public List<ProjektTable> Load(int id, DateTime from, DateTime until, Label message) { PositiveIntOrMinusOneValidator pimv = new PositiveIntOrMinusOneValidator(); DateValidator dvf = new DateValidator(); DateValidator dvu = new DateValidator(); string dateFrom = from.ToShortDateString(); string dateUntil = until.ToShortDateString(); pimv.Eval(id); dvf.Eval(dateFrom); dvu.Eval(dateUntil); if (pimv.HasErrors || dvf.HasErrors || dvu.HasErrors) { throw new InvalidInputException(); } // parse to date strings dateFrom = GlobalActions.ParseToSQLiteDateString(dateFrom); dateUntil = GlobalActions.ParseToSQLiteDateString(dateUntil); try { return DALFactory.GetDAL().LoadProjekte(dateFrom, dateUntil, id); } catch (SQLiteException) { throw; } }
public void EvalTest1() { PositiveIntOrMinusOneValidator target = new PositiveIntOrMinusOneValidator(); // TODO: Initialize to an appropriate value string input = "-1"; // TODO: Initialize to an appropriate value target.Eval(input); Assert.AreEqual(target.HasErrors, false); }
/// <summary> /// Load an existing Angebot out of the database /// </summary> /// <param name="kid">The referenced kundenID</param> /// <param name="from">From which date shall be searched from</param> /// <param name="until">Until which date shall be searched</param> /// <param name="msglabel">The label in which error messages can be written</param> /// <returns>The requested Angebote</returns> public List<AngebotTable> Load(int kid, DateTime from, DateTime until, Label msglabel, bool loadwithaid = false) { IRule posintormin1val = new PositiveIntOrMinusOneValidator(); IRule date1 = new DateValidator(); IRule date2 = new DateValidator(); DataBindingFramework.BindFromInt(kid.ToString(), "KundenID", msglabel, false, posintormin1val); string from_sds = DataBindingFramework.BindFromString(from.ToShortDateString(), "Von", msglabel, false, date1); string until_sds = DataBindingFramework.BindFromString(until.ToShortDateString(), "Bis", msglabel, false, date2); // parse to date strings from_sds = GlobalActions.ParseToSQLiteDateString(from_sds); until_sds = GlobalActions.ParseToSQLiteDateString(until_sds); if (posintormin1val.HasErrors) { this.logger.Log(Logger.Level.Error, "User tried to search Angebot with invalid KundenID!"); throw new InvalidInputException("Feld 'KundenID' ist ungültig!"); } else { try { return DALFactory.GetDAL().LoadAngebote(kid, from_sds, until_sds, loadwithaid); } catch (SQLiteException ex) { this.logger.Log(Logger.Level.Error, "Serious problem with database! " + ex.StackTrace + ex.Message); throw new DataBaseException(ex.Message); } catch (InvalidInputException ex) { this.logger.Log(Logger.Level.Error, "Some problem with the date strings occured. Search aborted."); throw new InvalidInputException(ex.Message); } } }