public void DrogueRunPosition_CRUD_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { DrogueRunPositionService drogueRunPositionService = new DrogueRunPositionService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); int count = 0; if (count == 1) { // just so we don't get a warning during compile [The variable 'count' is assigned but its value is never used] } DrogueRunPosition drogueRunPosition = GetFilledRandomDrogueRunPosition(""); // ------------------------------- // ------------------------------- // CRUD testing // ------------------------------- // ------------------------------- count = drogueRunPositionService.GetDrogueRunPositionList().Count(); Assert.AreEqual(count, (from c in dbTestDB.DrogueRunPositions select c).Count()); drogueRunPositionService.Add(drogueRunPosition); if (drogueRunPosition.HasErrors) { Assert.AreEqual("", drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(true, drogueRunPositionService.GetDrogueRunPositionList().Where(c => c == drogueRunPosition).Any()); drogueRunPositionService.Update(drogueRunPosition); if (drogueRunPosition.HasErrors) { Assert.AreEqual("", drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(count + 1, drogueRunPositionService.GetDrogueRunPositionList().Count()); drogueRunPositionService.Delete(drogueRunPosition); if (drogueRunPosition.HasErrors) { Assert.AreEqual("", drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(count, drogueRunPositionService.GetDrogueRunPositionList().Count()); } } }
public void GetDrogueRunPositionList_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { DrogueRunPositionService drogueRunPositionService = new DrogueRunPositionService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); DrogueRunPosition drogueRunPosition = (from c in dbTestDB.DrogueRunPositions select c).FirstOrDefault(); Assert.IsNotNull(drogueRunPosition); List <DrogueRunPosition> drogueRunPositionDirectQueryList = new List <DrogueRunPosition>(); drogueRunPositionDirectQueryList = (from c in dbTestDB.DrogueRunPositions select c).Take(200).ToList(); foreach (string extra in new List <string>() { null, "A", "B", "C", "D", "E" }) { drogueRunPositionService.Query.Extra = extra; if (string.IsNullOrWhiteSpace(extra)) { List <DrogueRunPosition> drogueRunPositionList = new List <DrogueRunPosition>(); drogueRunPositionList = drogueRunPositionService.GetDrogueRunPositionList().ToList(); CheckDrogueRunPositionFields(drogueRunPositionList); } else { //Assert.AreEqual(true, false); } } } } }
public void GetDrogueRunPositionList_2Where_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { foreach (string extra in new List <string>() { null, "A", "B", "C", "D", "E" }) { DrogueRunPositionService drogueRunPositionService = new DrogueRunPositionService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); drogueRunPositionService.Query = drogueRunPositionService.FillQuery(typeof(DrogueRunPosition), culture.TwoLetterISOLanguageName, 0, 10000, "", "", "DrogueRunPositionID,GT,2|DrogueRunPositionID,LT,5", extra); List <DrogueRunPosition> drogueRunPositionDirectQueryList = new List <DrogueRunPosition>(); drogueRunPositionDirectQueryList = (from c in dbTestDB.DrogueRunPositions select c).Where(c => c.DrogueRunPositionID > 2 && c.DrogueRunPositionID < 5).ToList(); if (string.IsNullOrWhiteSpace(extra)) { List <DrogueRunPosition> drogueRunPositionList = new List <DrogueRunPosition>(); drogueRunPositionList = drogueRunPositionService.GetDrogueRunPositionList().ToList(); CheckDrogueRunPositionFields(drogueRunPositionList); Assert.AreEqual(drogueRunPositionDirectQueryList[0].DrogueRunPositionID, drogueRunPositionList[0].DrogueRunPositionID); } else { //Assert.AreEqual(true, false); } } } } }
public IHttpActionResult GetDrogueRunPositionList([FromUri]string lang = "en", [FromUri]int skip = 0, [FromUri]int take = 200, [FromUri]string asc = "", [FromUri]string desc = "", [FromUri]string where = "", [FromUri]string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { DrogueRunPositionService drogueRunPositionService = new DrogueRunPositionService(new Query() { Lang = lang }, db, ContactID); if (extra == "A") // QueryString contains [extra=A] { drogueRunPositionService.Query = drogueRunPositionService.FillQuery(typeof(DrogueRunPositionExtraA), lang, skip, take, asc, desc, where, extra); if (drogueRunPositionService.Query.HasErrors) { return Ok(new List<DrogueRunPositionExtraA>() { new DrogueRunPositionExtraA() { HasErrors = drogueRunPositionService.Query.HasErrors, ValidationResults = drogueRunPositionService.Query.ValidationResults, }, }.ToList()); } else { return Ok(drogueRunPositionService.GetDrogueRunPositionExtraAList().ToList()); } } else if (extra == "B") // QueryString contains [extra=B] { drogueRunPositionService.Query = drogueRunPositionService.FillQuery(typeof(DrogueRunPositionExtraB), lang, skip, take, asc, desc, where, extra); if (drogueRunPositionService.Query.HasErrors) { return Ok(new List<DrogueRunPositionExtraB>() { new DrogueRunPositionExtraB() { HasErrors = drogueRunPositionService.Query.HasErrors, ValidationResults = drogueRunPositionService.Query.ValidationResults, }, }.ToList()); } else { return Ok(drogueRunPositionService.GetDrogueRunPositionExtraBList().ToList()); } } else // QueryString has no parameter [extra] or extra is empty { drogueRunPositionService.Query = drogueRunPositionService.FillQuery(typeof(DrogueRunPosition), lang, skip, take, asc, desc, where, extra); if (drogueRunPositionService.Query.HasErrors) { return Ok(new List<DrogueRunPosition>() { new DrogueRunPosition() { HasErrors = drogueRunPositionService.Query.HasErrors, ValidationResults = drogueRunPositionService.Query.ValidationResults, }, }.ToList()); } else { return Ok(drogueRunPositionService.GetDrogueRunPositionList().ToList()); } } } }
public void DrogueRunPosition_Properties_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { DrogueRunPositionService drogueRunPositionService = new DrogueRunPositionService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); int count = 0; if (count == 1) { // just so we don't get a warning during compile [The variable 'count' is assigned but its value is never used] } count = drogueRunPositionService.GetDrogueRunPositionList().Count(); DrogueRunPosition drogueRunPosition = GetFilledRandomDrogueRunPosition(""); // ------------------------------- // ------------------------------- // Properties testing // ------------------------------- // ------------------------------- // ----------------------------------- // [Key] // Is NOT Nullable // drogueRunPosition.DrogueRunPositionID (Int32) // ----------------------------------- drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.DrogueRunPositionID = 0; drogueRunPositionService.Update(drogueRunPosition); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "DrogueRunPositionID"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.DrogueRunPositionID = 10000000; drogueRunPositionService.Update(drogueRunPosition); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "DrogueRunPosition", "DrogueRunPositionID", drogueRunPosition.DrogueRunPositionID.ToString()), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "DrogueRun", ExistPlurial = "s", ExistFieldID = "DrogueRunID", AllowableTVtypeList = )] // drogueRunPosition.DrogueRunID (Int32) // ----------------------------------- drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.DrogueRunID = 0; drogueRunPositionService.Add(drogueRunPosition); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "DrogueRun", "DrogueRunID", drogueRunPosition.DrogueRunID.ToString()), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [Range(0, 100000)] // drogueRunPosition.Ordinal (Int32) // ----------------------------------- drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.Ordinal = -1; Assert.AreEqual(false, drogueRunPositionService.Add(drogueRunPosition)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Ordinal", "0", "100000"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, drogueRunPositionService.GetDrogueRunPositionList().Count()); drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.Ordinal = 100001; Assert.AreEqual(false, drogueRunPositionService.Add(drogueRunPosition)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Ordinal", "0", "100000"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, drogueRunPositionService.GetDrogueRunPositionList().Count()); // ----------------------------------- // Is NOT Nullable // [Range(-180, 180)] // drogueRunPosition.StepLat (Double) // ----------------------------------- //CSSPError: Type not implemented [StepLat] //CSSPError: Type not implemented [StepLat] drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.StepLat = -181.0D; Assert.AreEqual(false, drogueRunPositionService.Add(drogueRunPosition)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "StepLat", "-180", "180"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, drogueRunPositionService.GetDrogueRunPositionList().Count()); drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.StepLat = 181.0D; Assert.AreEqual(false, drogueRunPositionService.Add(drogueRunPosition)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "StepLat", "-180", "180"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, drogueRunPositionService.GetDrogueRunPositionList().Count()); // ----------------------------------- // Is NOT Nullable // [Range(-90, 90)] // drogueRunPosition.StepLng (Double) // ----------------------------------- //CSSPError: Type not implemented [StepLng] //CSSPError: Type not implemented [StepLng] drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.StepLng = -91.0D; Assert.AreEqual(false, drogueRunPositionService.Add(drogueRunPosition)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "StepLng", "-90", "90"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, drogueRunPositionService.GetDrogueRunPositionList().Count()); drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.StepLng = 91.0D; Assert.AreEqual(false, drogueRunPositionService.Add(drogueRunPosition)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "StepLng", "-90", "90"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, drogueRunPositionService.GetDrogueRunPositionList().Count()); // ----------------------------------- // Is NOT Nullable // [CSSPAfter(Year = 1980)] // drogueRunPosition.StepDateTime_Local (DateTime) // ----------------------------------- drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.StepDateTime_Local = new DateTime(); drogueRunPositionService.Add(drogueRunPosition); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "StepDateTime_Local"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.StepDateTime_Local = new DateTime(1979, 1, 1); drogueRunPositionService.Add(drogueRunPosition); Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "StepDateTime_Local", "1980"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [Range(0, 10)] // drogueRunPosition.CalculatedSpeed_m_s (Double) // ----------------------------------- //CSSPError: Type not implemented [CalculatedSpeed_m_s] //CSSPError: Type not implemented [CalculatedSpeed_m_s] drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.CalculatedSpeed_m_s = -1.0D; Assert.AreEqual(false, drogueRunPositionService.Add(drogueRunPosition)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "CalculatedSpeed_m_s", "0", "10"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, drogueRunPositionService.GetDrogueRunPositionList().Count()); drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.CalculatedSpeed_m_s = 11.0D; Assert.AreEqual(false, drogueRunPositionService.Add(drogueRunPosition)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "CalculatedSpeed_m_s", "0", "10"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, drogueRunPositionService.GetDrogueRunPositionList().Count()); // ----------------------------------- // Is NOT Nullable // [Range(0, 360)] // drogueRunPosition.CalculatedDirection_deg (Double) // ----------------------------------- //CSSPError: Type not implemented [CalculatedDirection_deg] //CSSPError: Type not implemented [CalculatedDirection_deg] drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.CalculatedDirection_deg = -1.0D; Assert.AreEqual(false, drogueRunPositionService.Add(drogueRunPosition)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "CalculatedDirection_deg", "0", "360"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, drogueRunPositionService.GetDrogueRunPositionList().Count()); drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.CalculatedDirection_deg = 361.0D; Assert.AreEqual(false, drogueRunPositionService.Add(drogueRunPosition)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "CalculatedDirection_deg", "0", "360"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, drogueRunPositionService.GetDrogueRunPositionList().Count()); // ----------------------------------- // Is NOT Nullable // [CSSPAfter(Year = 1980)] // drogueRunPosition.LastUpdateDate_UTC (DateTime) // ----------------------------------- drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.LastUpdateDate_UTC = new DateTime(); drogueRunPositionService.Add(drogueRunPosition); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "LastUpdateDate_UTC"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.LastUpdateDate_UTC = new DateTime(1979, 1, 1); drogueRunPositionService.Add(drogueRunPosition); Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "LastUpdateDate_UTC", "1980"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = Contact)] // drogueRunPosition.LastUpdateContactTVItemID (Int32) // ----------------------------------- drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.LastUpdateContactTVItemID = 0; drogueRunPositionService.Add(drogueRunPosition); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "LastUpdateContactTVItemID", drogueRunPosition.LastUpdateContactTVItemID.ToString()), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); drogueRunPosition = null; drogueRunPosition = GetFilledRandomDrogueRunPosition(""); drogueRunPosition.LastUpdateContactTVItemID = 1; drogueRunPositionService.Add(drogueRunPosition); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "LastUpdateContactTVItemID", "Contact"), drogueRunPosition.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [NotMapped] // drogueRunPosition.HasErrors (Boolean) // ----------------------------------- // No testing requied // ----------------------------------- // Is NOT Nullable // [NotMapped] // drogueRunPosition.ValidationResults (IEnumerable`1) // ----------------------------------- // No testing requied } } }