protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); _ReportSectionService = new ReportSectionService(LanguageRequest, User); _ReportTypeService = new ReportTypeService(LanguageRequest, User); _TVFileService = new TVFileService(LanguageRequest, User); _BaseEnumService = new BaseEnumService(LanguageRequest); }
public IHttpActionResult GetReportSectionList([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)) { ReportSectionService reportSectionService = new ReportSectionService(new Query() { Lang = lang }, db, ContactID);
public void ReportSection_Controller_Put_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { ReportSectionController reportSectionController = new ReportSectionController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(reportSectionController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportSectionController.DatabaseType); ReportSection reportSectionLast = new ReportSection(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { Query query = new Query(); query.Language = LanguageRequest; ReportSectionService reportSectionService = new ReportSectionService(query, db, ContactID); reportSectionLast = (from c in db.ReportSections select c).FirstOrDefault(); } // ok with ReportSection info IHttpActionResult jsonRet = reportSectionController.GetReportSectionWithID(reportSectionLast.ReportSectionID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <ReportSection> Ret = jsonRet as OkNegotiatedContentResult <ReportSection>; ReportSection reportSectionRet = Ret.Content; Assert.AreEqual(reportSectionLast.ReportSectionID, reportSectionRet.ReportSectionID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Put to return success IHttpActionResult jsonRet2 = reportSectionController.Put(reportSectionRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <ReportSection> reportSectionRet2 = jsonRet2 as OkNegotiatedContentResult <ReportSection>; Assert.IsNotNull(reportSectionRet2); BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult; Assert.IsNull(badRequest2); // Put to return CSSPError because ReportSectionID of 0 does not exist reportSectionRet.ReportSectionID = 0; IHttpActionResult jsonRet3 = reportSectionController.Put(reportSectionRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet3); OkNegotiatedContentResult <ReportSection> reportSectionRet3 = jsonRet3 as OkNegotiatedContentResult <ReportSection>; Assert.IsNull(reportSectionRet3); BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult; Assert.IsNotNull(badRequest3); } } }
public void SetupTest(LanguageEnum LanguageRequest) { csspWebToolsTaskRunner = new CSSPWebToolsTaskRunner(); _TVItemService = new TVItemService(LanguageRequest, csspWebToolsTaskRunner._TaskRunnerBaseService._User); _AppTaskService = new AppTaskService(LanguageRequest, csspWebToolsTaskRunner._TaskRunnerBaseService._User); _TVFileService = new TVFileService(LanguageRequest, csspWebToolsTaskRunner._TaskRunnerBaseService._User); _MapInfoService = new MapInfoService(LanguageRequest, csspWebToolsTaskRunner._TaskRunnerBaseService._User); _ReportTypeService = new ReportTypeService(LanguageRequest, csspWebToolsTaskRunner._TaskRunnerBaseService._User); _ReportSectionService = new ReportSectionService(LanguageRequest, csspWebToolsTaskRunner._TaskRunnerBaseService._User); }
public void ReportSection_CRUD_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { ReportSectionService reportSectionService = new ReportSectionService(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] } ReportSection reportSection = GetFilledRandomReportSection(""); // ------------------------------- // ------------------------------- // CRUD testing // ------------------------------- // ------------------------------- count = reportSectionService.GetReportSectionList().Count(); Assert.AreEqual(count, (from c in dbTestDB.ReportSections select c).Count()); reportSectionService.Add(reportSection); if (reportSection.HasErrors) { Assert.AreEqual("", reportSection.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(true, reportSectionService.GetReportSectionList().Where(c => c == reportSection).Any()); reportSectionService.Update(reportSection); if (reportSection.HasErrors) { Assert.AreEqual("", reportSection.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(count + 1, reportSectionService.GetReportSectionList().Count()); reportSectionService.Delete(reportSection); if (reportSection.HasErrors) { Assert.AreEqual("", reportSection.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(count, reportSectionService.GetReportSectionList().Count()); } } }
public IHttpActionResult GetReportSectionWithID([FromUri] int ReportSectionID, [FromUri] string lang = "en", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { ReportSectionService reportSectionService = new ReportSectionService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); reportSectionService.Query = reportSectionService.FillQuery(typeof(ReportSection), lang, 0, 1, "", "", extra); if (reportSectionService.Query.Extra == "A") { ReportSectionExtraA reportSectionExtraA = new ReportSectionExtraA(); reportSectionExtraA = reportSectionService.GetReportSectionExtraAWithReportSectionID(ReportSectionID); if (reportSectionExtraA == null) { return(NotFound()); } return(Ok(reportSectionExtraA)); } else if (reportSectionService.Query.Extra == "B") { ReportSectionExtraB reportSectionExtraB = new ReportSectionExtraB(); reportSectionExtraB = reportSectionService.GetReportSectionExtraBWithReportSectionID(ReportSectionID); if (reportSectionExtraB == null) { return(NotFound()); } return(Ok(reportSectionExtraB)); } else { ReportSection reportSection = new ReportSection(); reportSection = reportSectionService.GetReportSectionWithReportSectionID(ReportSectionID); if (reportSection == null) { return(NotFound()); } return(Ok(reportSection)); } } }
public void ReportSection_Controller_GetReportSectionWithID_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { ReportSectionController reportSectionController = new ReportSectionController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(reportSectionController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportSectionController.DatabaseType); ReportSection reportSectionFirst = new ReportSection(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { ReportSectionService reportSectionService = new ReportSectionService(new Query(), db, ContactID); reportSectionFirst = (from c in db.ReportSections select c).FirstOrDefault(); } // ok with ReportSection info IHttpActionResult jsonRet = reportSectionController.GetReportSectionWithID(reportSectionFirst.ReportSectionID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <ReportSection> Ret = jsonRet as OkNegotiatedContentResult <ReportSection>; ReportSection reportSectionRet = Ret.Content; Assert.AreEqual(reportSectionFirst.ReportSectionID, reportSectionRet.ReportSectionID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Not Found IHttpActionResult jsonRet2 = reportSectionController.GetReportSectionWithID(0); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <ReportSection> reportSectionRet2 = jsonRet2 as OkNegotiatedContentResult <ReportSection>; Assert.IsNull(reportSectionRet2); NotFoundResult notFoundRequest = jsonRet2 as NotFoundResult; Assert.IsNotNull(notFoundRequest); } } }
public IHttpActionResult Delete([FromBody] ReportSection reportSection, [FromUri] string lang = "en") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { ReportSectionService reportSectionService = new ReportSectionService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); if (!reportSectionService.Delete(reportSection)) { return(BadRequest(String.Join("|||", reportSection.ValidationResults))); } else { reportSection.ValidationResults = null; return(Ok(reportSection)); } } }
public void GetReportSectionList_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { ReportSectionService reportSectionService = new ReportSectionService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); ReportSection reportSection = (from c in dbTestDB.ReportSections select c).FirstOrDefault(); Assert.IsNotNull(reportSection); List <ReportSection> reportSectionDirectQueryList = new List <ReportSection>(); reportSectionDirectQueryList = (from c in dbTestDB.ReportSections select c).Take(200).ToList(); foreach (string extra in new List <string>() { null, "A", "B", "C", "D", "E" }) { reportSectionService.Query.Extra = extra; if (string.IsNullOrWhiteSpace(extra)) { List <ReportSection> reportSectionList = new List <ReportSection>(); reportSectionList = reportSectionService.GetReportSectionList().ToList(); CheckReportSectionFields(reportSectionList); } else { //Assert.AreEqual(true, false); } } } } }
public void GetReportSectionList_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" }) { ReportSectionService reportSectionService = new ReportSectionService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); reportSectionService.Query = reportSectionService.FillQuery(typeof(ReportSection), culture.TwoLetterISOLanguageName, 0, 10000, "", "", "ReportSectionID,GT,2|ReportSectionID,LT,5", extra); List <ReportSection> reportSectionDirectQueryList = new List <ReportSection>(); reportSectionDirectQueryList = (from c in dbTestDB.ReportSections select c).Where(c => c.ReportSectionID > 2 && c.ReportSectionID < 5).ToList(); if (string.IsNullOrWhiteSpace(extra)) { List <ReportSection> reportSectionList = new List <ReportSection>(); reportSectionList = reportSectionService.GetReportSectionList().ToList(); CheckReportSectionFields(reportSectionList); Assert.AreEqual(reportSectionDirectQueryList[0].ReportSectionID, reportSectionList[0].ReportSectionID); } else { //Assert.AreEqual(true, false); } } } } }
public IHttpActionResult GetReportSectionList([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)) { ReportSectionService reportSectionService = new ReportSectionService(new Query() { Lang = lang }, db, ContactID); if (extra == "A") // QueryString contains [extra=A] { reportSectionService.Query = reportSectionService.FillQuery(typeof(ReportSectionExtraA), lang, skip, take, asc, desc, where, extra); if (reportSectionService.Query.HasErrors) { return(Ok(new List <ReportSectionExtraA>() { new ReportSectionExtraA() { HasErrors = reportSectionService.Query.HasErrors, ValidationResults = reportSectionService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(reportSectionService.GetReportSectionExtraAList().ToList())); } } else if (extra == "B") // QueryString contains [extra=B] { reportSectionService.Query = reportSectionService.FillQuery(typeof(ReportSectionExtraB), lang, skip, take, asc, desc, where, extra); if (reportSectionService.Query.HasErrors) { return(Ok(new List <ReportSectionExtraB>() { new ReportSectionExtraB() { HasErrors = reportSectionService.Query.HasErrors, ValidationResults = reportSectionService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(reportSectionService.GetReportSectionExtraBList().ToList())); } } else // QueryString has no parameter [extra] or extra is empty { reportSectionService.Query = reportSectionService.FillQuery(typeof(ReportSection), lang, skip, take, asc, desc, where, extra); if (reportSectionService.Query.HasErrors) { return(Ok(new List <ReportSection>() { new ReportSection() { HasErrors = reportSectionService.Query.HasErrors, ValidationResults = reportSectionService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(reportSectionService.GetReportSectionList().ToList())); } } } }
public void ReportSection_Controller_GetReportSectionList_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { ReportSectionController reportSectionController = new ReportSectionController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(reportSectionController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportSectionController.DatabaseType); ReportSection reportSectionFirst = new ReportSection(); int count = -1; Query query = new Query(); using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { ReportSectionService reportSectionService = new ReportSectionService(query, db, ContactID); reportSectionFirst = (from c in db.ReportSections select c).FirstOrDefault(); count = (from c in db.ReportSections select c).Count(); count = (query.Take > count ? count : query.Take); } // ok with ReportSection info IHttpActionResult jsonRet = reportSectionController.GetReportSectionList(); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <List <ReportSection> > ret = jsonRet as OkNegotiatedContentResult <List <ReportSection> >; Assert.AreEqual(reportSectionFirst.ReportSectionID, ret.Content[0].ReportSectionID); Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count); List <ReportSection> reportSectionList = new List <ReportSection>(); count = -1; query = new Query(); using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { ReportSectionService reportSectionService = new ReportSectionService(query, db, ContactID); reportSectionList = (from c in db.ReportSections select c).OrderBy(c => c.ReportSectionID).Skip(0).Take(2).ToList(); count = (from c in db.ReportSections select c).Count(); } if (count > 0) { query.Skip = 0; query.Take = 5; count = (query.Take > count ? query.Take : count); // ok with ReportSection info jsonRet = reportSectionController.GetReportSectionList(query.Language.ToString(), query.Skip, query.Take); Assert.IsNotNull(jsonRet); ret = jsonRet as OkNegotiatedContentResult <List <ReportSection> >; Assert.AreEqual(reportSectionList[0].ReportSectionID, ret.Content[0].ReportSectionID); 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 ReportSection info IHttpActionResult jsonRet2 = reportSectionController.GetReportSectionList(query.Language.ToString(), query.Skip, query.Take); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <List <ReportSection> > ret2 = jsonRet2 as OkNegotiatedContentResult <List <ReportSection> >; Assert.AreEqual(reportSectionList[1].ReportSectionID, ret2.Content[0].ReportSectionID); Assert.AreEqual((count > query.Take ? query.Take : count), ret2.Content.Count); } } } } }
public void ReportSection_Controller_Post_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { ReportSectionController reportSectionController = new ReportSectionController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(reportSectionController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportSectionController.DatabaseType); ReportSection reportSectionLast = new ReportSection(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { Query query = new Query(); query.Language = LanguageRequest; query.Asc = ""; query.Desc = ""; ReportSectionService reportSectionService = new ReportSectionService(query, db, ContactID); reportSectionLast = (from c in db.ReportSections select c).FirstOrDefault(); } // ok with ReportSection info IHttpActionResult jsonRet = reportSectionController.GetReportSectionWithID(reportSectionLast.ReportSectionID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <ReportSection> Ret = jsonRet as OkNegotiatedContentResult <ReportSection>; ReportSection reportSectionRet = Ret.Content; Assert.AreEqual(reportSectionLast.ReportSectionID, reportSectionRet.ReportSectionID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Post to return CSSPError because ReportSectionID exist IHttpActionResult jsonRet2 = reportSectionController.Post(reportSectionRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <ReportSection> reportSectionRet2 = jsonRet2 as OkNegotiatedContentResult <ReportSection>; Assert.IsNull(reportSectionRet2); BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult; Assert.IsNotNull(badRequest2); // Post to return newly added ReportSection reportSectionRet.ReportSectionID = 0; reportSectionController.Request = new System.Net.Http.HttpRequestMessage(); reportSectionController.Request.RequestUri = new System.Uri("http://localhost:5000/api/reportSection"); IHttpActionResult jsonRet3 = reportSectionController.Post(reportSectionRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet3); CreatedNegotiatedContentResult <ReportSection> reportSectionRet3 = jsonRet3 as CreatedNegotiatedContentResult <ReportSection>; Assert.IsNotNull(reportSectionRet3); BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult; Assert.IsNull(badRequest3); IHttpActionResult jsonRet4 = reportSectionController.Delete(reportSectionRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet4); OkNegotiatedContentResult <ReportSection> reportSectionRet4 = jsonRet4 as OkNegotiatedContentResult <ReportSection>; Assert.IsNotNull(reportSectionRet4); BadRequestErrorMessageResult badRequest4 = jsonRet4 as BadRequestErrorMessageResult; Assert.IsNull(badRequest4); } } }
public void ReportSection_Properties_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { ReportSectionService reportSectionService = new ReportSectionService(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 = reportSectionService.GetReportSectionList().Count(); ReportSection reportSection = GetFilledRandomReportSection(""); // ------------------------------- // ------------------------------- // Properties testing // ------------------------------- // ------------------------------- // ----------------------------------- // [Key] // Is NOT Nullable // reportSection.ReportSectionID (Int32) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.ReportSectionID = 0; reportSectionService.Update(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "ReportSectionID"), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.ReportSectionID = 10000000; reportSectionService.Update(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "ReportSection", "ReportSectionID", reportSection.ReportSectionID.ToString()), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "ReportType", ExistPlurial = "s", ExistFieldID = "ReportTypeID", AllowableTVtypeList = )] // reportSection.ReportTypeID (Int32) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.ReportTypeID = 0; reportSectionService.Add(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "ReportType", "ReportTypeID", reportSection.ReportTypeID.ToString()), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = )] // reportSection.TVItemID (Int32) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.TVItemID = 0; reportSectionService.Add(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "TVItemID", reportSection.TVItemID.ToString()), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.TVItemID = 1; reportSectionService.Add(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "TVItemID", ""), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is Nullable // [CSSPEnumType] // reportSection.Language (LanguageEnum) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.Language = (LanguageEnum)1000000; reportSectionService.Add(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "Language"), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [Range(0, 1000)] // reportSection.Ordinal (Int32) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.Ordinal = -1; Assert.AreEqual(false, reportSectionService.Add(reportSection)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Ordinal", "0", "1000"), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, reportSectionService.GetReportSectionList().Count()); reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.Ordinal = 1001; Assert.AreEqual(false, reportSectionService.Add(reportSection)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Ordinal", "0", "1000"), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, reportSectionService.GetReportSectionList().Count()); // ----------------------------------- // Is NOT Nullable // reportSection.IsStatic (Boolean) // ----------------------------------- // ----------------------------------- // Is Nullable // [CSSPExist(ExistTypeName = "ReportSection", ExistPlurial = "s", ExistFieldID = "ReportSectionID", AllowableTVtypeList = )] // reportSection.ParentReportSectionID (Int32) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.ParentReportSectionID = 0; reportSectionService.Add(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "ReportSection", "ParentReportSectionID", reportSection.ParentReportSectionID.ToString()), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is Nullable // [Range(1979, 2050)] // reportSection.Year (Int32) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.Year = 1978; Assert.AreEqual(false, reportSectionService.Add(reportSection)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Year", "1979", "2050"), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, reportSectionService.GetReportSectionList().Count()); reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.Year = 2051; Assert.AreEqual(false, reportSectionService.Add(reportSection)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Year", "1979", "2050"), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, reportSectionService.GetReportSectionList().Count()); // ----------------------------------- // Is NOT Nullable // reportSection.Locked (Boolean) // ----------------------------------- // ----------------------------------- // Is Nullable // [CSSPExist(ExistTypeName = "ReportSection", ExistPlurial = "s", ExistFieldID = "ReportSectionID", AllowableTVtypeList = )] // reportSection.TemplateReportSectionID (Int32) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.TemplateReportSectionID = 0; reportSectionService.Add(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "ReportSection", "TemplateReportSectionID", reportSection.TemplateReportSectionID.ToString()), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is Nullable // [StringLength(100))] // reportSection.ReportSectionName (String) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.ReportSectionName = GetRandomString("", 101); Assert.AreEqual(false, reportSectionService.Add(reportSection)); Assert.AreEqual(string.Format(CSSPServicesRes._MaxLengthIs_, "ReportSectionName", "100"), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, reportSectionService.GetReportSectionList().Count()); // ----------------------------------- // Is Nullable // [StringLength(10000))] // reportSection.ReportSectionText (String) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.ReportSectionText = GetRandomString("", 10001); Assert.AreEqual(false, reportSectionService.Add(reportSection)); Assert.AreEqual(string.Format(CSSPServicesRes._MaxLengthIs_, "ReportSectionText", "10000"), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, reportSectionService.GetReportSectionList().Count()); // ----------------------------------- // Is NOT Nullable // [CSSPAfter(Year = 1980)] // reportSection.LastUpdateDate_UTC (DateTime) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.LastUpdateDate_UTC = new DateTime(); reportSectionService.Add(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "LastUpdateDate_UTC"), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.LastUpdateDate_UTC = new DateTime(1979, 1, 1); reportSectionService.Add(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "LastUpdateDate_UTC", "1980"), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = Contact)] // reportSection.LastUpdateContactTVItemID (Int32) // ----------------------------------- reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.LastUpdateContactTVItemID = 0; reportSectionService.Add(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "LastUpdateContactTVItemID", reportSection.LastUpdateContactTVItemID.ToString()), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); reportSection = null; reportSection = GetFilledRandomReportSection(""); reportSection.LastUpdateContactTVItemID = 1; reportSectionService.Add(reportSection); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "LastUpdateContactTVItemID", "Contact"), reportSection.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [NotMapped] // reportSection.HasErrors (Boolean) // ----------------------------------- // No testing requied // ----------------------------------- // Is NOT Nullable // [NotMapped] // reportSection.ValidationResults (IEnumerable`1) // ----------------------------------- // No testing requied } } }