public TVItemUserAuthorizationService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public EmailDistributionListContactLanguageService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public void VPScenario_Controller_Delete_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { VPScenarioController vpScenarioController = new VPScenarioController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(vpScenarioController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, vpScenarioController.DatabaseType); VPScenario vpScenarioLast = new VPScenario(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { Query query = new Query(); query.Language = LanguageRequest; query.Asc = ""; query.Desc = ""; VPScenarioService vpScenarioService = new VPScenarioService(query, db, ContactID); vpScenarioLast = (from c in db.VPScenarios select c).FirstOrDefault(); } // ok with VPScenario info IHttpActionResult jsonRet = vpScenarioController.GetVPScenarioWithID(vpScenarioLast.VPScenarioID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <VPScenario> Ret = jsonRet as OkNegotiatedContentResult <VPScenario>; VPScenario vpScenarioRet = Ret.Content; Assert.AreEqual(vpScenarioLast.VPScenarioID, vpScenarioRet.VPScenarioID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Post to return newly added VPScenario vpScenarioRet.VPScenarioID = 0; vpScenarioController.Request = new System.Net.Http.HttpRequestMessage(); vpScenarioController.Request.RequestUri = new System.Uri("http://localhost:5000/api/vpScenario"); IHttpActionResult jsonRet3 = vpScenarioController.Post(vpScenarioRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet3); CreatedNegotiatedContentResult <VPScenario> vpScenarioRet3 = jsonRet3 as CreatedNegotiatedContentResult <VPScenario>; Assert.IsNotNull(vpScenarioRet3); VPScenario vpScenario = vpScenarioRet3.Content; BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult; Assert.IsNull(badRequest3); // Delete to return success IHttpActionResult jsonRet2 = vpScenarioController.Delete(vpScenarioRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <VPScenario> vpScenarioRet2 = jsonRet2 as OkNegotiatedContentResult <VPScenario>; Assert.IsNotNull(vpScenarioRet2); BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult; Assert.IsNull(badRequest2); // Delete to return CSSPError because VPScenarioID of 0 does not exist vpScenarioRet.VPScenarioID = 0; IHttpActionResult jsonRet4 = vpScenarioController.Delete(vpScenarioRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet4); OkNegotiatedContentResult <VPScenario> vpScenarioRet4 = jsonRet4 as OkNegotiatedContentResult <VPScenario>; Assert.IsNull(vpScenarioRet4); BadRequestErrorMessageResult badRequest4 = jsonRet4 as BadRequestErrorMessageResult; Assert.IsNotNull(badRequest4); } } }
public void UseOfSite_Properties_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { UseOfSiteService useOfSiteService = new UseOfSiteService(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 = useOfSiteService.GetUseOfSiteList().Count(); UseOfSite useOfSite = GetFilledRandomUseOfSite(""); // ------------------------------- // ------------------------------- // Properties testing // ------------------------------- // ------------------------------- // ----------------------------------- // [Key] // Is NOT Nullable // useOfSite.UseOfSiteID (Int32) // ----------------------------------- useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.UseOfSiteID = 0; useOfSiteService.Update(useOfSite); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "UseOfSiteID"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.UseOfSiteID = 10000000; useOfSiteService.Update(useOfSite); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "UseOfSite", "UseOfSiteID", useOfSite.UseOfSiteID.ToString()), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = ClimateSite,HydrometricSite,TideSite)] // useOfSite.SiteTVItemID (Int32) // ----------------------------------- useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.SiteTVItemID = 0; useOfSiteService.Add(useOfSite); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "SiteTVItemID", useOfSite.SiteTVItemID.ToString()), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.SiteTVItemID = 1; useOfSiteService.Add(useOfSite); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "SiteTVItemID", "ClimateSite,HydrometricSite,TideSite"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = Subsector)] // useOfSite.SubsectorTVItemID (Int32) // ----------------------------------- useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.SubsectorTVItemID = 0; useOfSiteService.Add(useOfSite); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "SubsectorTVItemID", useOfSite.SubsectorTVItemID.ToString()), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.SubsectorTVItemID = 1; useOfSiteService.Add(useOfSite); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "SubsectorTVItemID", "Subsector"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPEnumType] // useOfSite.TVType (TVTypeEnum) // ----------------------------------- useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.TVType = (TVTypeEnum)1000000; useOfSiteService.Add(useOfSite); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "TVType"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [Range(0, 1000)] // useOfSite.Ordinal (Int32) // ----------------------------------- useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Ordinal = -1; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Ordinal", "0", "1000"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Ordinal = 1001; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Ordinal", "0", "1000"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); // ----------------------------------- // Is NOT Nullable // [Range(1980, 2050)] // useOfSite.StartYear (Int32) // ----------------------------------- useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.StartYear = 1979; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "StartYear", "1980", "2050"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.StartYear = 2051; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "StartYear", "1980", "2050"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); // ----------------------------------- // Is Nullable // [Range(1980, 2050)] // useOfSite.EndYear (Int32) // ----------------------------------- useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.EndYear = 1979; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "EndYear", "1980", "2050"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.EndYear = 2051; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "EndYear", "1980", "2050"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); // ----------------------------------- // Is Nullable // useOfSite.UseWeight (Boolean) // ----------------------------------- // ----------------------------------- // Is Nullable // [Range(0, 100)] // useOfSite.Weight_perc (Double) // ----------------------------------- //CSSPError: Type not implemented [Weight_perc] //CSSPError: Type not implemented [Weight_perc] useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Weight_perc = -1.0D; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Weight_perc", "0", "100"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Weight_perc = 101.0D; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Weight_perc", "0", "100"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); // ----------------------------------- // Is Nullable // useOfSite.UseEquation (Boolean) // ----------------------------------- // ----------------------------------- // Is Nullable // [Range(0, 100)] // useOfSite.Param1 (Double) // ----------------------------------- //CSSPError: Type not implemented [Param1] //CSSPError: Type not implemented [Param1] useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Param1 = -1.0D; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Param1", "0", "100"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Param1 = 101.0D; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Param1", "0", "100"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); // ----------------------------------- // Is Nullable // [Range(0, 100)] // useOfSite.Param2 (Double) // ----------------------------------- //CSSPError: Type not implemented [Param2] //CSSPError: Type not implemented [Param2] useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Param2 = -1.0D; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Param2", "0", "100"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Param2 = 101.0D; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Param2", "0", "100"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); // ----------------------------------- // Is Nullable // [Range(0, 100)] // useOfSite.Param3 (Double) // ----------------------------------- //CSSPError: Type not implemented [Param3] //CSSPError: Type not implemented [Param3] useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Param3 = -1.0D; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Param3", "0", "100"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Param3 = 101.0D; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Param3", "0", "100"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); // ----------------------------------- // Is Nullable // [Range(0, 100)] // useOfSite.Param4 (Double) // ----------------------------------- //CSSPError: Type not implemented [Param4] //CSSPError: Type not implemented [Param4] useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Param4 = -1.0D; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Param4", "0", "100"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.Param4 = 101.0D; Assert.AreEqual(false, useOfSiteService.Add(useOfSite)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Param4", "0", "100"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, useOfSiteService.GetUseOfSiteList().Count()); // ----------------------------------- // Is NOT Nullable // [CSSPAfter(Year = 1980)] // useOfSite.LastUpdateDate_UTC (DateTime) // ----------------------------------- useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.LastUpdateDate_UTC = new DateTime(); useOfSiteService.Add(useOfSite); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "LastUpdateDate_UTC"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.LastUpdateDate_UTC = new DateTime(1979, 1, 1); useOfSiteService.Add(useOfSite); Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "LastUpdateDate_UTC", "1980"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = Contact)] // useOfSite.LastUpdateContactTVItemID (Int32) // ----------------------------------- useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.LastUpdateContactTVItemID = 0; useOfSiteService.Add(useOfSite); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "LastUpdateContactTVItemID", useOfSite.LastUpdateContactTVItemID.ToString()), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); useOfSite = null; useOfSite = GetFilledRandomUseOfSite(""); useOfSite.LastUpdateContactTVItemID = 1; useOfSiteService.Add(useOfSite); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "LastUpdateContactTVItemID", "Contact"), useOfSite.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [NotMapped] // useOfSite.HasErrors (Boolean) // ----------------------------------- // No testing requied // ----------------------------------- // Is NOT Nullable // [NotMapped] // useOfSite.ValidationResults (IEnumerable`1) // ----------------------------------- // No testing requied } } }
public IHttpActionResult GetTVFileLanguageList([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)) { TVFileLanguageService tvFileLanguageService = new TVFileLanguageService(new Query() { Lang = lang }, db, ContactID); if (extra == "A") // QueryString contains [extra=A] { tvFileLanguageService.Query = tvFileLanguageService.FillQuery(typeof(TVFileLanguageExtraA), lang, skip, take, asc, desc, where, extra); if (tvFileLanguageService.Query.HasErrors) { return(Ok(new List <TVFileLanguageExtraA>() { new TVFileLanguageExtraA() { HasErrors = tvFileLanguageService.Query.HasErrors, ValidationResults = tvFileLanguageService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(tvFileLanguageService.GetTVFileLanguageExtraAList().ToList())); } } else if (extra == "B") // QueryString contains [extra=B] { tvFileLanguageService.Query = tvFileLanguageService.FillQuery(typeof(TVFileLanguageExtraB), lang, skip, take, asc, desc, where, extra); if (tvFileLanguageService.Query.HasErrors) { return(Ok(new List <TVFileLanguageExtraB>() { new TVFileLanguageExtraB() { HasErrors = tvFileLanguageService.Query.HasErrors, ValidationResults = tvFileLanguageService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(tvFileLanguageService.GetTVFileLanguageExtraBList().ToList())); } } else // QueryString has no parameter [extra] or extra is empty { tvFileLanguageService.Query = tvFileLanguageService.FillQuery(typeof(TVFileLanguage), lang, skip, take, asc, desc, where, extra); if (tvFileLanguageService.Query.HasErrors) { return(Ok(new List <TVFileLanguage>() { new TVFileLanguage() { HasErrors = tvFileLanguageService.Query.HasErrors, ValidationResults = tvFileLanguageService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(tvFileLanguageService.GetTVFileLanguageList().ToList())); } } } }
/// <summary> /// CSSPDB SamplingPlanAndFilesLabSheetCounts table service constructor /// </summary> /// <param name="query">[Query](CSSPModels.Query.html) object for filtering of service functions</param> /// <param name="db">[CSSPDBContext](CSSPModels.CSSPDBContext.html) referencing the CSSP database context</param> /// <param name="ContactID">Representing the contact identifier of the person connecting to the service</param> public SamplingPlanAndFilesLabSheetCountService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
/// <summary> /// CSSPDB InputSummarys table service constructor /// </summary> /// <param name="query">[Query](CSSPModels.Query.html) object for filtering of service functions</param> /// <param name="db">[CSSPDBContext](CSSPModels.CSSPDBContext.html) referencing the CSSP database context</param> /// <param name="ContactID">Representing the contact identifier of the person connecting to the service</param> public InputSummaryService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public ResetPasswordService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public ReportSectionService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
/// <summary> /// CSSPDB Registers table service constructor /// </summary> /// <param name="query">[Query](CSSPModels.Query.html) object for filtering of service functions</param> /// <param name="db">[CSSPDBContext](CSSPModels.CSSPDBContext.html) referencing the CSSP database context</param> /// <param name="ContactID">Representing the contact identifier of the person connecting to the service</param> public RegisterService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public void TVFileLanguage_Controller_Delete_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { TVFileLanguageController tvFileLanguageController = new TVFileLanguageController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(tvFileLanguageController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, tvFileLanguageController.DatabaseType); TVFileLanguage tvFileLanguageLast = new TVFileLanguage(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { Query query = new Query(); query.Language = LanguageRequest; query.Asc = ""; query.Desc = ""; TVFileLanguageService tvFileLanguageService = new TVFileLanguageService(query, db, ContactID); tvFileLanguageLast = (from c in db.TVFileLanguages select c).FirstOrDefault(); } // ok with TVFileLanguage info IHttpActionResult jsonRet = tvFileLanguageController.GetTVFileLanguageWithID(tvFileLanguageLast.TVFileLanguageID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <TVFileLanguage> Ret = jsonRet as OkNegotiatedContentResult <TVFileLanguage>; TVFileLanguage tvFileLanguageRet = Ret.Content; Assert.AreEqual(tvFileLanguageLast.TVFileLanguageID, tvFileLanguageRet.TVFileLanguageID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Post to return newly added TVFileLanguage tvFileLanguageRet.TVFileLanguageID = 0; tvFileLanguageController.Request = new System.Net.Http.HttpRequestMessage(); tvFileLanguageController.Request.RequestUri = new System.Uri("http://localhost:5000/api/tvFileLanguage"); IHttpActionResult jsonRet3 = tvFileLanguageController.Post(tvFileLanguageRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet3); CreatedNegotiatedContentResult <TVFileLanguage> tvFileLanguageRet3 = jsonRet3 as CreatedNegotiatedContentResult <TVFileLanguage>; Assert.IsNotNull(tvFileLanguageRet3); TVFileLanguage tvFileLanguage = tvFileLanguageRet3.Content; BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult; Assert.IsNull(badRequest3); // Delete to return success IHttpActionResult jsonRet2 = tvFileLanguageController.Delete(tvFileLanguageRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <TVFileLanguage> tvFileLanguageRet2 = jsonRet2 as OkNegotiatedContentResult <TVFileLanguage>; Assert.IsNotNull(tvFileLanguageRet2); BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult; Assert.IsNull(badRequest2); // Delete to return CSSPError because TVFileLanguageID of 0 does not exist tvFileLanguageRet.TVFileLanguageID = 0; IHttpActionResult jsonRet4 = tvFileLanguageController.Delete(tvFileLanguageRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet4); OkNegotiatedContentResult <TVFileLanguage> tvFileLanguageRet4 = jsonRet4 as OkNegotiatedContentResult <TVFileLanguage>; Assert.IsNull(tvFileLanguageRet4); BadRequestErrorMessageResult badRequest4 = jsonRet4 as BadRequestErrorMessageResult; Assert.IsNotNull(badRequest4); } } }
/// <summary> /// CSSPDB LabSheetA1Sheets table service constructor /// </summary> /// <param name="query">[Query](CSSPModels.Query.html) object for filtering of service functions</param> /// <param name="db">[CSSPDBContext](CSSPModels.CSSPDBContext.html) referencing the CSSP database context</param> /// <param name="ContactID">Representing the contact identifier of the person connecting to the service</param> public LabSheetA1SheetService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public void ContactPreference_Controller_Post_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { ContactPreferenceController contactPreferenceController = new ContactPreferenceController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(contactPreferenceController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, contactPreferenceController.DatabaseType); ContactPreference contactPreferenceLast = new ContactPreference(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { Query query = new Query(); query.Language = LanguageRequest; query.Asc = ""; query.Desc = ""; ContactPreferenceService contactPreferenceService = new ContactPreferenceService(query, db, ContactID); contactPreferenceLast = (from c in db.ContactPreferences select c).FirstOrDefault(); } // ok with ContactPreference info IHttpActionResult jsonRet = contactPreferenceController.GetContactPreferenceWithID(contactPreferenceLast.ContactPreferenceID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <ContactPreference> Ret = jsonRet as OkNegotiatedContentResult <ContactPreference>; ContactPreference contactPreferenceRet = Ret.Content; Assert.AreEqual(contactPreferenceLast.ContactPreferenceID, contactPreferenceRet.ContactPreferenceID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Post to return CSSPError because ContactPreferenceID exist IHttpActionResult jsonRet2 = contactPreferenceController.Post(contactPreferenceRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <ContactPreference> contactPreferenceRet2 = jsonRet2 as OkNegotiatedContentResult <ContactPreference>; Assert.IsNull(contactPreferenceRet2); BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult; Assert.IsNotNull(badRequest2); // Post to return newly added ContactPreference contactPreferenceRet.ContactPreferenceID = 0; contactPreferenceController.Request = new System.Net.Http.HttpRequestMessage(); contactPreferenceController.Request.RequestUri = new System.Uri("http://localhost:5000/api/contactPreference"); IHttpActionResult jsonRet3 = contactPreferenceController.Post(contactPreferenceRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet3); CreatedNegotiatedContentResult <ContactPreference> contactPreferenceRet3 = jsonRet3 as CreatedNegotiatedContentResult <ContactPreference>; Assert.IsNotNull(contactPreferenceRet3); BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult; Assert.IsNull(badRequest3); IHttpActionResult jsonRet4 = contactPreferenceController.Delete(contactPreferenceRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet4); OkNegotiatedContentResult <ContactPreference> contactPreferenceRet4 = jsonRet4 as OkNegotiatedContentResult <ContactPreference>; Assert.IsNotNull(contactPreferenceRet4); BadRequestErrorMessageResult badRequest4 = jsonRet4 as BadRequestErrorMessageResult; Assert.IsNull(badRequest4); } } }
/// <summary> /// CSSPDB BoxModelResults table service constructor /// </summary> /// <param name="query">[Query](CSSPModels.Query.html) object for filtering of service functions</param> /// <param name="db">[CSSPDBContext](CSSPModels.CSSPDBContext.html) referencing the CSSP database context</param> /// <param name="ContactID">Representing the contact identifier of the person connecting to the service</param> public BoxModelResultService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public void EmailDistributionListContact_Properties_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { EmailDistributionListContactService emailDistributionListContactService = new EmailDistributionListContactService(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 = emailDistributionListContactService.GetEmailDistributionListContactList().Count(); EmailDistributionListContact emailDistributionListContact = GetFilledRandomEmailDistributionListContact(""); // ------------------------------- // ------------------------------- // Properties testing // ------------------------------- // ------------------------------- // ----------------------------------- // [Key] // Is NOT Nullable // emailDistributionListContact.EmailDistributionListContactID (Int32) // ----------------------------------- emailDistributionListContact = null; emailDistributionListContact = GetFilledRandomEmailDistributionListContact(""); emailDistributionListContact.EmailDistributionListContactID = 0; emailDistributionListContactService.Update(emailDistributionListContact); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "EmailDistributionListContactID"), emailDistributionListContact.ValidationResults.FirstOrDefault().ErrorMessage); emailDistributionListContact = null; emailDistributionListContact = GetFilledRandomEmailDistributionListContact(""); emailDistributionListContact.EmailDistributionListContactID = 10000000; emailDistributionListContactService.Update(emailDistributionListContact); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "EmailDistributionListContact", "EmailDistributionListContactID", emailDistributionListContact.EmailDistributionListContactID.ToString()), emailDistributionListContact.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "EmailDistributionList", ExistPlurial = "s", ExistFieldID = "EmailDistributionListID", AllowableTVtypeList = )] // emailDistributionListContact.EmailDistributionListID (Int32) // ----------------------------------- emailDistributionListContact = null; emailDistributionListContact = GetFilledRandomEmailDistributionListContact(""); emailDistributionListContact.EmailDistributionListID = 0; emailDistributionListContactService.Add(emailDistributionListContact); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "EmailDistributionList", "EmailDistributionListID", emailDistributionListContact.EmailDistributionListID.ToString()), emailDistributionListContact.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // emailDistributionListContact.IsCC (Boolean) // ----------------------------------- // ----------------------------------- // Is NOT Nullable // [StringLength(100))] // emailDistributionListContact.Name (String) // ----------------------------------- emailDistributionListContact = null; emailDistributionListContact = GetFilledRandomEmailDistributionListContact("Name"); Assert.AreEqual(false, emailDistributionListContactService.Add(emailDistributionListContact)); Assert.AreEqual(1, emailDistributionListContact.ValidationResults.Count()); Assert.IsTrue(emailDistributionListContact.ValidationResults.Where(c => c.ErrorMessage == string.Format(CSSPServicesRes._IsRequired, "Name")).Any()); Assert.AreEqual(null, emailDistributionListContact.Name); Assert.AreEqual(count, emailDistributionListContactService.GetEmailDistributionListContactList().Count()); emailDistributionListContact = null; emailDistributionListContact = GetFilledRandomEmailDistributionListContact(""); emailDistributionListContact.Name = GetRandomString("", 101); Assert.AreEqual(false, emailDistributionListContactService.Add(emailDistributionListContact)); Assert.AreEqual(string.Format(CSSPServicesRes._MaxLengthIs_, "Name", "100"), emailDistributionListContact.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, emailDistributionListContactService.GetEmailDistributionListContactList().Count()); // ----------------------------------- // Is NOT Nullable // [DataType(DataType.EmailAddress)] // [StringLength(200))] // emailDistributionListContact.Email (String) // ----------------------------------- emailDistributionListContact = null; emailDistributionListContact = GetFilledRandomEmailDistributionListContact("Email"); Assert.AreEqual(false, emailDistributionListContactService.Add(emailDistributionListContact)); Assert.AreEqual(1, emailDistributionListContact.ValidationResults.Count()); Assert.IsTrue(emailDistributionListContact.ValidationResults.Where(c => c.ErrorMessage == string.Format(CSSPServicesRes._IsRequired, "Email")).Any()); Assert.AreEqual(null, emailDistributionListContact.Email); Assert.AreEqual(count, emailDistributionListContactService.GetEmailDistributionListContactList().Count()); emailDistributionListContact = null; emailDistributionListContact = GetFilledRandomEmailDistributionListContact(""); emailDistributionListContact.Email = GetRandomString("", 201); Assert.AreEqual(false, emailDistributionListContactService.Add(emailDistributionListContact)); Assert.AreEqual(string.Format(CSSPServicesRes._MaxLengthIs_, "Email", "200"), emailDistributionListContact.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, emailDistributionListContactService.GetEmailDistributionListContactList().Count()); // ----------------------------------- // Is NOT Nullable // emailDistributionListContact.CMPRainfallSeasonal (Boolean) // ----------------------------------- // ----------------------------------- // Is NOT Nullable // emailDistributionListContact.CMPWastewater (Boolean) // ----------------------------------- // ----------------------------------- // Is NOT Nullable // emailDistributionListContact.EmergencyWeather (Boolean) // ----------------------------------- // ----------------------------------- // Is NOT Nullable // emailDistributionListContact.EmergencyWastewater (Boolean) // ----------------------------------- // ----------------------------------- // Is NOT Nullable // emailDistributionListContact.ReopeningAllTypes (Boolean) // ----------------------------------- // ----------------------------------- // Is NOT Nullable // [CSSPAfter(Year = 1980)] // emailDistributionListContact.LastUpdateDate_UTC (DateTime) // ----------------------------------- emailDistributionListContact = null; emailDistributionListContact = GetFilledRandomEmailDistributionListContact(""); emailDistributionListContact.LastUpdateDate_UTC = new DateTime(); emailDistributionListContactService.Add(emailDistributionListContact); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "LastUpdateDate_UTC"), emailDistributionListContact.ValidationResults.FirstOrDefault().ErrorMessage); emailDistributionListContact = null; emailDistributionListContact = GetFilledRandomEmailDistributionListContact(""); emailDistributionListContact.LastUpdateDate_UTC = new DateTime(1979, 1, 1); emailDistributionListContactService.Add(emailDistributionListContact); Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "LastUpdateDate_UTC", "1980"), emailDistributionListContact.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = Contact)] // emailDistributionListContact.LastUpdateContactTVItemID (Int32) // ----------------------------------- emailDistributionListContact = null; emailDistributionListContact = GetFilledRandomEmailDistributionListContact(""); emailDistributionListContact.LastUpdateContactTVItemID = 0; emailDistributionListContactService.Add(emailDistributionListContact); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "LastUpdateContactTVItemID", emailDistributionListContact.LastUpdateContactTVItemID.ToString()), emailDistributionListContact.ValidationResults.FirstOrDefault().ErrorMessage); emailDistributionListContact = null; emailDistributionListContact = GetFilledRandomEmailDistributionListContact(""); emailDistributionListContact.LastUpdateContactTVItemID = 1; emailDistributionListContactService.Add(emailDistributionListContact); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "LastUpdateContactTVItemID", "Contact"), emailDistributionListContact.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [NotMapped] // emailDistributionListContact.HasErrors (Boolean) // ----------------------------------- // No testing requied // ----------------------------------- // Is NOT Nullable // [NotMapped] // emailDistributionListContact.ValidationResults (IEnumerable`1) // ----------------------------------- // No testing requied } } }
public MWQMSiteStartEndDateService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public MikeSourceService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public PolSourceGroupingService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public ContactPreferenceService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public void PolSourceSiteEffectTerm_Controller_Delete_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { PolSourceSiteEffectTermController polSourceSiteEffectTermController = new PolSourceSiteEffectTermController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(polSourceSiteEffectTermController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, polSourceSiteEffectTermController.DatabaseType); PolSourceSiteEffectTerm polSourceSiteEffectTermLast = new PolSourceSiteEffectTerm(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { Query query = new Query(); query.Language = LanguageRequest; query.Asc = ""; query.Desc = ""; PolSourceSiteEffectTermService polSourceSiteEffectTermService = new PolSourceSiteEffectTermService(query, db, ContactID); polSourceSiteEffectTermLast = (from c in db.PolSourceSiteEffectTerms select c).FirstOrDefault(); } // ok with PolSourceSiteEffectTerm info IHttpActionResult jsonRet = polSourceSiteEffectTermController.GetPolSourceSiteEffectTermWithID(polSourceSiteEffectTermLast.PolSourceSiteEffectTermID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <PolSourceSiteEffectTerm> Ret = jsonRet as OkNegotiatedContentResult <PolSourceSiteEffectTerm>; PolSourceSiteEffectTerm polSourceSiteEffectTermRet = Ret.Content; Assert.AreEqual(polSourceSiteEffectTermLast.PolSourceSiteEffectTermID, polSourceSiteEffectTermRet.PolSourceSiteEffectTermID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Post to return newly added PolSourceSiteEffectTerm polSourceSiteEffectTermRet.PolSourceSiteEffectTermID = 0; polSourceSiteEffectTermController.Request = new System.Net.Http.HttpRequestMessage(); polSourceSiteEffectTermController.Request.RequestUri = new System.Uri("http://localhost:5000/api/polSourceSiteEffectTerm"); IHttpActionResult jsonRet3 = polSourceSiteEffectTermController.Post(polSourceSiteEffectTermRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet3); CreatedNegotiatedContentResult <PolSourceSiteEffectTerm> polSourceSiteEffectTermRet3 = jsonRet3 as CreatedNegotiatedContentResult <PolSourceSiteEffectTerm>; Assert.IsNotNull(polSourceSiteEffectTermRet3); PolSourceSiteEffectTerm polSourceSiteEffectTerm = polSourceSiteEffectTermRet3.Content; BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult; Assert.IsNull(badRequest3); // Delete to return success IHttpActionResult jsonRet2 = polSourceSiteEffectTermController.Delete(polSourceSiteEffectTermRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <PolSourceSiteEffectTerm> polSourceSiteEffectTermRet2 = jsonRet2 as OkNegotiatedContentResult <PolSourceSiteEffectTerm>; Assert.IsNotNull(polSourceSiteEffectTermRet2); BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult; Assert.IsNull(badRequest2); // Delete to return CSSPError because PolSourceSiteEffectTermID of 0 does not exist polSourceSiteEffectTermRet.PolSourceSiteEffectTermID = 0; IHttpActionResult jsonRet4 = polSourceSiteEffectTermController.Delete(polSourceSiteEffectTermRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet4); OkNegotiatedContentResult <PolSourceSiteEffectTerm> polSourceSiteEffectTermRet4 = jsonRet4 as OkNegotiatedContentResult <PolSourceSiteEffectTerm>; Assert.IsNull(polSourceSiteEffectTermRet4); BadRequestErrorMessageResult badRequest4 = jsonRet4 as BadRequestErrorMessageResult; Assert.IsNotNull(badRequest4); } } }
/// <summary> /// CSSPDB Spills table service constructor /// </summary> /// <param name="query">[Query](CSSPModels.Query.html) object for filtering of service functions</param> /// <param name="db">[CSSPDBContext](CSSPModels.CSSPDBContext.html) referencing the CSSP database context</param> /// <param name="ContactID">Representing the contact identifier of the person connecting to the service</param> public SpillService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public void PolSourceSiteEffectTerm_Controller_GetPolSourceSiteEffectTermList_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { PolSourceSiteEffectTermController polSourceSiteEffectTermController = new PolSourceSiteEffectTermController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(polSourceSiteEffectTermController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, polSourceSiteEffectTermController.DatabaseType); PolSourceSiteEffectTerm polSourceSiteEffectTermFirst = new PolSourceSiteEffectTerm(); int count = -1; Query query = new Query(); using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { PolSourceSiteEffectTermService polSourceSiteEffectTermService = new PolSourceSiteEffectTermService(query, db, ContactID); polSourceSiteEffectTermFirst = (from c in db.PolSourceSiteEffectTerms select c).FirstOrDefault(); count = (from c in db.PolSourceSiteEffectTerms select c).Count(); count = (query.Take > count ? count : query.Take); } // ok with PolSourceSiteEffectTerm info IHttpActionResult jsonRet = polSourceSiteEffectTermController.GetPolSourceSiteEffectTermList(); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <List <PolSourceSiteEffectTerm> > ret = jsonRet as OkNegotiatedContentResult <List <PolSourceSiteEffectTerm> >; Assert.AreEqual(polSourceSiteEffectTermFirst.PolSourceSiteEffectTermID, ret.Content[0].PolSourceSiteEffectTermID); Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count); List <PolSourceSiteEffectTerm> polSourceSiteEffectTermList = new List <PolSourceSiteEffectTerm>(); count = -1; query = new Query(); using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { PolSourceSiteEffectTermService polSourceSiteEffectTermService = new PolSourceSiteEffectTermService(query, db, ContactID); polSourceSiteEffectTermList = (from c in db.PolSourceSiteEffectTerms select c).OrderBy(c => c.PolSourceSiteEffectTermID).Skip(0).Take(2).ToList(); count = (from c in db.PolSourceSiteEffectTerms select c).Count(); } if (count > 0) { query.Skip = 0; query.Take = 5; count = (query.Take > count ? query.Take : count); // ok with PolSourceSiteEffectTerm info jsonRet = polSourceSiteEffectTermController.GetPolSourceSiteEffectTermList(query.Language.ToString(), query.Skip, query.Take); Assert.IsNotNull(jsonRet); ret = jsonRet as OkNegotiatedContentResult <List <PolSourceSiteEffectTerm> >; Assert.AreEqual(polSourceSiteEffectTermList[0].PolSourceSiteEffectTermID, ret.Content[0].PolSourceSiteEffectTermID); Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count); if (count > 1) { query.Skip = 1; query.Take = 5; count = (query.Take > count ? query.Take : count); // ok with PolSourceSiteEffectTerm info IHttpActionResult jsonRet2 = polSourceSiteEffectTermController.GetPolSourceSiteEffectTermList(query.Language.ToString(), query.Skip, query.Take); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <List <PolSourceSiteEffectTerm> > ret2 = jsonRet2 as OkNegotiatedContentResult <List <PolSourceSiteEffectTerm> >; Assert.AreEqual(polSourceSiteEffectTermList[1].PolSourceSiteEffectTermID, ret2.Content[0].PolSourceSiteEffectTermID); Assert.AreEqual((count > query.Take ? query.Take : count), ret2.Content.Count); } } } } }
public VPScenarioService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public TideLocationService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public AppTaskService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
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 } } }
public TVItemTVAuthService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }
public void ResetPassword_Properties_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { ResetPasswordService resetPasswordService = new ResetPasswordService(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 = resetPasswordService.GetResetPasswordList().Count(); ResetPassword resetPassword = GetFilledRandomResetPassword(""); // ------------------------------- // ------------------------------- // Properties testing // ------------------------------- // ------------------------------- // ----------------------------------- // [Key] // Is NOT Nullable // resetPassword.ResetPasswordID (Int32) // ----------------------------------- resetPassword = null; resetPassword = GetFilledRandomResetPassword(""); resetPassword.ResetPasswordID = 0; resetPasswordService.Update(resetPassword); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "ResetPasswordID"), resetPassword.ValidationResults.FirstOrDefault().ErrorMessage); resetPassword = null; resetPassword = GetFilledRandomResetPassword(""); resetPassword.ResetPasswordID = 10000000; resetPasswordService.Update(resetPassword); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "ResetPassword", "ResetPasswordID", resetPassword.ResetPasswordID.ToString()), resetPassword.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [DataType(DataType.EmailAddress)] // [StringLength(256))] // resetPassword.Email (String) // ----------------------------------- resetPassword = null; resetPassword = GetFilledRandomResetPassword("Email"); Assert.AreEqual(false, resetPasswordService.Add(resetPassword)); Assert.AreEqual(1, resetPassword.ValidationResults.Count()); Assert.IsTrue(resetPassword.ValidationResults.Where(c => c.ErrorMessage == string.Format(CSSPServicesRes._IsRequired, "Email")).Any()); Assert.AreEqual(null, resetPassword.Email); Assert.AreEqual(count, resetPasswordService.GetResetPasswordList().Count()); resetPassword = null; resetPassword = GetFilledRandomResetPassword(""); resetPassword.Email = GetRandomString("", 257); Assert.AreEqual(false, resetPasswordService.Add(resetPassword)); Assert.AreEqual(string.Format(CSSPServicesRes._MaxLengthIs_, "Email", "256"), resetPassword.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, resetPasswordService.GetResetPasswordList().Count()); // ----------------------------------- // Is NOT Nullable // [CSSPAfter(Year = 1980)] // resetPassword.ExpireDate_Local (DateTime) // ----------------------------------- resetPassword = null; resetPassword = GetFilledRandomResetPassword(""); resetPassword.ExpireDate_Local = new DateTime(); resetPasswordService.Add(resetPassword); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "ExpireDate_Local"), resetPassword.ValidationResults.FirstOrDefault().ErrorMessage); resetPassword = null; resetPassword = GetFilledRandomResetPassword(""); resetPassword.ExpireDate_Local = new DateTime(1979, 1, 1); resetPasswordService.Add(resetPassword); Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "ExpireDate_Local", "1980"), resetPassword.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [StringLength(8))] // resetPassword.Code (String) // ----------------------------------- resetPassword = null; resetPassword = GetFilledRandomResetPassword("Code"); Assert.AreEqual(false, resetPasswordService.Add(resetPassword)); Assert.AreEqual(1, resetPassword.ValidationResults.Count()); Assert.IsTrue(resetPassword.ValidationResults.Where(c => c.ErrorMessage == string.Format(CSSPServicesRes._IsRequired, "Code")).Any()); Assert.AreEqual(null, resetPassword.Code); Assert.AreEqual(count, resetPasswordService.GetResetPasswordList().Count()); resetPassword = null; resetPassword = GetFilledRandomResetPassword(""); resetPassword.Code = GetRandomString("", 9); Assert.AreEqual(false, resetPasswordService.Add(resetPassword)); Assert.AreEqual(string.Format(CSSPServicesRes._MaxLengthIs_, "Code", "8"), resetPassword.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, resetPasswordService.GetResetPasswordList().Count()); // ----------------------------------- // Is NOT Nullable // [CSSPAfter(Year = 1980)] // resetPassword.LastUpdateDate_UTC (DateTime) // ----------------------------------- resetPassword = null; resetPassword = GetFilledRandomResetPassword(""); resetPassword.LastUpdateDate_UTC = new DateTime(); resetPasswordService.Add(resetPassword); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "LastUpdateDate_UTC"), resetPassword.ValidationResults.FirstOrDefault().ErrorMessage); resetPassword = null; resetPassword = GetFilledRandomResetPassword(""); resetPassword.LastUpdateDate_UTC = new DateTime(1979, 1, 1); resetPasswordService.Add(resetPassword); Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "LastUpdateDate_UTC", "1980"), resetPassword.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = Contact)] // resetPassword.LastUpdateContactTVItemID (Int32) // ----------------------------------- resetPassword = null; resetPassword = GetFilledRandomResetPassword(""); resetPassword.LastUpdateContactTVItemID = 0; resetPasswordService.Add(resetPassword); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "LastUpdateContactTVItemID", resetPassword.LastUpdateContactTVItemID.ToString()), resetPassword.ValidationResults.FirstOrDefault().ErrorMessage); resetPassword = null; resetPassword = GetFilledRandomResetPassword(""); resetPassword.LastUpdateContactTVItemID = 1; resetPasswordService.Add(resetPassword); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "LastUpdateContactTVItemID", "Contact"), resetPassword.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [NotMapped] // resetPassword.HasErrors (Boolean) // ----------------------------------- // No testing requied // ----------------------------------- // Is NOT Nullable // [NotMapped] // resetPassword.ValidationResults (IEnumerable`1) // ----------------------------------- // No testing requied } } }
public void VPScenario_Controller_GetVPScenarioList_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { VPScenarioController vpScenarioController = new VPScenarioController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(vpScenarioController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, vpScenarioController.DatabaseType); VPScenario vpScenarioFirst = new VPScenario(); int count = -1; Query query = new Query(); using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { VPScenarioService vpScenarioService = new VPScenarioService(query, db, ContactID); vpScenarioFirst = (from c in db.VPScenarios select c).FirstOrDefault(); count = (from c in db.VPScenarios select c).Count(); count = (query.Take > count ? count : query.Take); } // ok with VPScenario info IHttpActionResult jsonRet = vpScenarioController.GetVPScenarioList(); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <List <VPScenario> > ret = jsonRet as OkNegotiatedContentResult <List <VPScenario> >; Assert.AreEqual(vpScenarioFirst.VPScenarioID, ret.Content[0].VPScenarioID); Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count); List <VPScenario> vpScenarioList = new List <VPScenario>(); count = -1; query = new Query(); using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { VPScenarioService vpScenarioService = new VPScenarioService(query, db, ContactID); vpScenarioList = (from c in db.VPScenarios select c).OrderBy(c => c.VPScenarioID).Skip(0).Take(2).ToList(); count = (from c in db.VPScenarios select c).Count(); } if (count > 0) { query.Skip = 0; query.Take = 5; count = (query.Take > count ? query.Take : count); // ok with VPScenario info jsonRet = vpScenarioController.GetVPScenarioList(query.Language.ToString(), query.Skip, query.Take); Assert.IsNotNull(jsonRet); ret = jsonRet as OkNegotiatedContentResult <List <VPScenario> >; Assert.AreEqual(vpScenarioList[0].VPScenarioID, ret.Content[0].VPScenarioID); Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count); if (count > 1) { query.Skip = 1; query.Take = 5; count = (query.Take > count ? query.Take : count); // ok with VPScenario info IHttpActionResult jsonRet2 = vpScenarioController.GetVPScenarioList(query.Language.ToString(), query.Skip, query.Take); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <List <VPScenario> > ret2 = jsonRet2 as OkNegotiatedContentResult <List <VPScenario> >; Assert.AreEqual(vpScenarioList[1].VPScenarioID, ret2.Content[0].VPScenarioID); Assert.AreEqual((count > query.Take ? query.Take : count), ret2.Content.Count); } } } } }
public ContourPolygonService(Query query, CSSPDBContext db, int ContactID) : base(query, db, ContactID) { }