public void RainExceedanceClimateSite_CRUD_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { RainExceedanceClimateSiteService rainExceedanceClimateSiteService = new RainExceedanceClimateSiteService(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] } RainExceedanceClimateSite rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); // ------------------------------- // ------------------------------- // CRUD testing // ------------------------------- // ------------------------------- count = rainExceedanceClimateSiteService.GetRainExceedanceClimateSiteList().Count(); Assert.AreEqual(count, (from c in dbTestDB.RainExceedanceClimateSites select c).Count()); rainExceedanceClimateSiteService.Add(rainExceedanceClimateSite); if (rainExceedanceClimateSite.HasErrors) { Assert.AreEqual("", rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(true, rainExceedanceClimateSiteService.GetRainExceedanceClimateSiteList().Where(c => c == rainExceedanceClimateSite).Any()); rainExceedanceClimateSiteService.Update(rainExceedanceClimateSite); if (rainExceedanceClimateSite.HasErrors) { Assert.AreEqual("", rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(count + 1, rainExceedanceClimateSiteService.GetRainExceedanceClimateSiteList().Count()); rainExceedanceClimateSiteService.Delete(rainExceedanceClimateSite); if (rainExceedanceClimateSite.HasErrors) { Assert.AreEqual("", rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(count, rainExceedanceClimateSiteService.GetRainExceedanceClimateSiteList().Count()); } } }
public void RainExceedanceClimateSite_Properties_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { RainExceedanceClimateSiteService rainExceedanceClimateSiteService = new RainExceedanceClimateSiteService(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 = rainExceedanceClimateSiteService.GetRainExceedanceClimateSiteList().Count(); RainExceedanceClimateSite rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); // ------------------------------- // ------------------------------- // Properties testing // ------------------------------- // ------------------------------- // ----------------------------------- // [Key] // Is NOT Nullable // rainExceedanceClimateSite.RainExceedanceClimateSiteID (Int32) // ----------------------------------- rainExceedanceClimateSite = null; rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); rainExceedanceClimateSite.RainExceedanceClimateSiteID = 0; rainExceedanceClimateSiteService.Update(rainExceedanceClimateSite); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "RainExceedanceClimateSiteID"), rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); rainExceedanceClimateSite = null; rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); rainExceedanceClimateSite.RainExceedanceClimateSiteID = 10000000; rainExceedanceClimateSiteService.Update(rainExceedanceClimateSite); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "RainExceedanceClimateSite", "RainExceedanceClimateSiteID", rainExceedanceClimateSite.RainExceedanceClimateSiteID.ToString()), rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = RainExceedance)] // rainExceedanceClimateSite.RainExceedanceTVItemID (Int32) // ----------------------------------- rainExceedanceClimateSite = null; rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); rainExceedanceClimateSite.RainExceedanceTVItemID = 0; rainExceedanceClimateSiteService.Add(rainExceedanceClimateSite); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "RainExceedanceTVItemID", rainExceedanceClimateSite.RainExceedanceTVItemID.ToString()), rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); rainExceedanceClimateSite = null; rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); rainExceedanceClimateSite.RainExceedanceTVItemID = 1; rainExceedanceClimateSiteService.Add(rainExceedanceClimateSite); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "RainExceedanceTVItemID", "RainExceedance"), rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = ClimateSite)] // rainExceedanceClimateSite.ClimateSiteTVItemID (Int32) // ----------------------------------- rainExceedanceClimateSite = null; rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); rainExceedanceClimateSite.ClimateSiteTVItemID = 0; rainExceedanceClimateSiteService.Add(rainExceedanceClimateSite); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "ClimateSiteTVItemID", rainExceedanceClimateSite.ClimateSiteTVItemID.ToString()), rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); rainExceedanceClimateSite = null; rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); rainExceedanceClimateSite.ClimateSiteTVItemID = 1; rainExceedanceClimateSiteService.Add(rainExceedanceClimateSite); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "ClimateSiteTVItemID", "ClimateSite"), rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPAfter(Year = 1980)] // rainExceedanceClimateSite.LastUpdateDate_UTC (DateTime) // ----------------------------------- rainExceedanceClimateSite = null; rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); rainExceedanceClimateSite.LastUpdateDate_UTC = new DateTime(); rainExceedanceClimateSiteService.Add(rainExceedanceClimateSite); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "LastUpdateDate_UTC"), rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); rainExceedanceClimateSite = null; rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); rainExceedanceClimateSite.LastUpdateDate_UTC = new DateTime(1979, 1, 1); rainExceedanceClimateSiteService.Add(rainExceedanceClimateSite); Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "LastUpdateDate_UTC", "1980"), rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = Contact)] // rainExceedanceClimateSite.LastUpdateContactTVItemID (Int32) // ----------------------------------- rainExceedanceClimateSite = null; rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); rainExceedanceClimateSite.LastUpdateContactTVItemID = 0; rainExceedanceClimateSiteService.Add(rainExceedanceClimateSite); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "LastUpdateContactTVItemID", rainExceedanceClimateSite.LastUpdateContactTVItemID.ToString()), rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); rainExceedanceClimateSite = null; rainExceedanceClimateSite = GetFilledRandomRainExceedanceClimateSite(""); rainExceedanceClimateSite.LastUpdateContactTVItemID = 1; rainExceedanceClimateSiteService.Add(rainExceedanceClimateSite); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "LastUpdateContactTVItemID", "Contact"), rainExceedanceClimateSite.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [NotMapped] // rainExceedanceClimateSite.HasErrors (Boolean) // ----------------------------------- // No testing requied // ----------------------------------- // Is NOT Nullable // [NotMapped] // rainExceedanceClimateSite.ValidationResults (IEnumerable`1) // ----------------------------------- // No testing requied } } }