public Cache_BO() { //reportDailyService = new ReportDailyService(); reportTypeService = new ReportTypeService(); dataObservationMongoService = new DataObservationMongoService(); sitesService = new SitesService(); }
public ReportTypeServiceTest() { this.service = new ReportTypeService(); this.listOptions = new ReportTypeListOptions { }; }
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 void ReportType_Controller_Put_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { ReportTypeController reportTypeController = new ReportTypeController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(reportTypeController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportTypeController.DatabaseType); ReportType reportTypeLast = new ReportType(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { Query query = new Query(); query.Language = LanguageRequest; ReportTypeService reportTypeService = new ReportTypeService(query, db, ContactID); reportTypeLast = (from c in db.ReportTypes select c).FirstOrDefault(); } // ok with ReportType info IHttpActionResult jsonRet = reportTypeController.GetReportTypeWithID(reportTypeLast.ReportTypeID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <ReportType> Ret = jsonRet as OkNegotiatedContentResult <ReportType>; ReportType reportTypeRet = Ret.Content; Assert.AreEqual(reportTypeLast.ReportTypeID, reportTypeRet.ReportTypeID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Put to return success IHttpActionResult jsonRet2 = reportTypeController.Put(reportTypeRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <ReportType> reportTypeRet2 = jsonRet2 as OkNegotiatedContentResult <ReportType>; Assert.IsNotNull(reportTypeRet2); BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult; Assert.IsNull(badRequest2); // Put to return CSSPError because ReportTypeID of 0 does not exist reportTypeRet.ReportTypeID = 0; IHttpActionResult jsonRet3 = reportTypeController.Put(reportTypeRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet3); OkNegotiatedContentResult <ReportType> reportTypeRet3 = jsonRet3 as OkNegotiatedContentResult <ReportType>; Assert.IsNull(reportTypeRet3); BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult; Assert.IsNotNull(badRequest3); } } }
public ReportTypeServiceTest(MockHttpClientFixture mockHttpClientFixture) : base(mockHttpClientFixture) { this.service = new ReportTypeService(); this.listOptions = new ReportTypeListOptions { }; }
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); }
public IHttpActionResult GetReportTypeList([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)) { ReportTypeService reportTypeService = new ReportTypeService(new Query() { Lang = lang }, db, ContactID);
public ReportTypeServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new ReportTypeService(this.StripeClient); this.listOptions = new ReportTypeListOptions { }; }
public void ReportType_CRUD_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { ReportTypeService reportTypeService = new ReportTypeService(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] } ReportType reportType = GetFilledRandomReportType(""); // ------------------------------- // ------------------------------- // CRUD testing // ------------------------------- // ------------------------------- count = reportTypeService.GetReportTypeList().Count(); Assert.AreEqual(count, (from c in dbTestDB.ReportTypes select c).Count()); reportTypeService.Add(reportType); if (reportType.HasErrors) { Assert.AreEqual("", reportType.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(true, reportTypeService.GetReportTypeList().Where(c => c == reportType).Any()); reportTypeService.Update(reportType); if (reportType.HasErrors) { Assert.AreEqual("", reportType.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(count + 1, reportTypeService.GetReportTypeList().Count()); reportTypeService.Delete(reportType); if (reportType.HasErrors) { Assert.AreEqual("", reportType.ValidationResults.FirstOrDefault().ErrorMessage); } Assert.AreEqual(count, reportTypeService.GetReportTypeList().Count()); } } }
public IHttpActionResult GetReportTypeWithID([FromUri] int ReportTypeID, [FromUri] string lang = "en", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { ReportTypeService reportTypeService = new ReportTypeService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); reportTypeService.Query = reportTypeService.FillQuery(typeof(ReportType), lang, 0, 1, "", "", extra); if (reportTypeService.Query.Extra == "A") { ReportTypeExtraA reportTypeExtraA = new ReportTypeExtraA(); reportTypeExtraA = reportTypeService.GetReportTypeExtraAWithReportTypeID(ReportTypeID); if (reportTypeExtraA == null) { return(NotFound()); } return(Ok(reportTypeExtraA)); } else if (reportTypeService.Query.Extra == "B") { ReportTypeExtraB reportTypeExtraB = new ReportTypeExtraB(); reportTypeExtraB = reportTypeService.GetReportTypeExtraBWithReportTypeID(ReportTypeID); if (reportTypeExtraB == null) { return(NotFound()); } return(Ok(reportTypeExtraB)); } else { ReportType reportType = new ReportType(); reportType = reportTypeService.GetReportTypeWithReportTypeID(ReportTypeID); if (reportType == null) { return(NotFound()); } return(Ok(reportType)); } } }
public ReportController() { dataObservationMongoService = new DataObservationMongoService(); dataAlarmMongoService = new DataAlarmMongoService(); areasService = new AreasService(); sitesService = new SitesService(); groupService = new GroupService(); observationService = new ObservationService(); userProfileService = new UserProfileService(); reportTypeService = new ReportTypeService(); reportDailyNhietDoService = new ReportDailyNhietDoService(); reportDailyMucNuocService = new ReportDailyMucNuocService(); reportDailyLuongMuaService = new ReportDailyLuongMuaService(); reportDailyApSuatService = new ReportDailyApSuatService(); reportDailyDoAmService = new ReportDailyDoAmService(); reportDailyTocDoGioService = new ReportDailyTocDoGioService(); reportDailyHuongGioService = new ReportDailyHuongGioService(); }
public JsonResult Edit(ReportTypeModel reporttype) { try { if (reporttype.Id > 0) { ReportTypeService.UpdateReportType(reporttype); } else { ReportTypeService.CreateReportType(ref reporttype); } return(Json(new { Status = "OK", ItemId = reporttype.Id }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Status = "ERROR", ItemId = 0 }, JsonRequestBehavior.AllowGet)); } }
public void ReportType_Controller_GetReportTypeWithID_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { ReportTypeController reportTypeController = new ReportTypeController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(reportTypeController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportTypeController.DatabaseType); ReportType reportTypeFirst = new ReportType(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { ReportTypeService reportTypeService = new ReportTypeService(new Query(), db, ContactID); reportTypeFirst = (from c in db.ReportTypes select c).FirstOrDefault(); } // ok with ReportType info IHttpActionResult jsonRet = reportTypeController.GetReportTypeWithID(reportTypeFirst.ReportTypeID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <ReportType> Ret = jsonRet as OkNegotiatedContentResult <ReportType>; ReportType reportTypeRet = Ret.Content; Assert.AreEqual(reportTypeFirst.ReportTypeID, reportTypeRet.ReportTypeID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Not Found IHttpActionResult jsonRet2 = reportTypeController.GetReportTypeWithID(0); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <ReportType> reportTypeRet2 = jsonRet2 as OkNegotiatedContentResult <ReportType>; Assert.IsNull(reportTypeRet2); NotFoundResult notFoundRequest = jsonRet2 as NotFoundResult; Assert.IsNotNull(notFoundRequest); } } }
public IHttpActionResult Delete([FromBody] ReportType reportType, [FromUri] string lang = "en") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { ReportTypeService reportTypeService = new ReportTypeService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); if (!reportTypeService.Delete(reportType)) { return(BadRequest(String.Join("|||", reportType.ValidationResults))); } else { reportType.ValidationResults = null; return(Ok(reportType)); } } }
public void GetReportTypeList_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { ReportTypeService reportTypeService = new ReportTypeService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); ReportType reportType = (from c in dbTestDB.ReportTypes select c).FirstOrDefault(); Assert.IsNotNull(reportType); List <ReportType> reportTypeDirectQueryList = new List <ReportType>(); reportTypeDirectQueryList = (from c in dbTestDB.ReportTypes select c).Take(200).ToList(); foreach (string extra in new List <string>() { null, "A", "B", "C", "D", "E" }) { reportTypeService.Query.Extra = extra; if (string.IsNullOrWhiteSpace(extra)) { List <ReportType> reportTypeList = new List <ReportType>(); reportTypeList = reportTypeService.GetReportTypeList().ToList(); CheckReportTypeFields(reportTypeList); } else { //Assert.AreEqual(true, false); } } } } }
public void GetReportTypeList_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" }) { ReportTypeService reportTypeService = new ReportTypeService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); reportTypeService.Query = reportTypeService.FillQuery(typeof(ReportType), culture.TwoLetterISOLanguageName, 0, 10000, "", "", "ReportTypeID,GT,2|ReportTypeID,LT,5", extra); List <ReportType> reportTypeDirectQueryList = new List <ReportType>(); reportTypeDirectQueryList = (from c in dbTestDB.ReportTypes select c).Where(c => c.ReportTypeID > 2 && c.ReportTypeID < 5).ToList(); if (string.IsNullOrWhiteSpace(extra)) { List <ReportType> reportTypeList = new List <ReportType>(); reportTypeList = reportTypeService.GetReportTypeList().ToList(); CheckReportTypeFields(reportTypeList); Assert.AreEqual(reportTypeDirectQueryList[0].ReportTypeID, reportTypeList[0].ReportTypeID); } else { //Assert.AreEqual(true, false); } } } } }
public JsonResult GetReportTypes() { return(Json(ReportTypeService.GetReportTypes().ToList <ReportTypeModel>(), JsonRequestBehavior.AllowGet)); }
public void ReportType_Controller_Post_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { ReportTypeController reportTypeController = new ReportTypeController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(reportTypeController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportTypeController.DatabaseType); ReportType reportTypeLast = new ReportType(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { Query query = new Query(); query.Language = LanguageRequest; query.Asc = ""; query.Desc = ""; ReportTypeService reportTypeService = new ReportTypeService(query, db, ContactID); reportTypeLast = (from c in db.ReportTypes select c).FirstOrDefault(); } // ok with ReportType info IHttpActionResult jsonRet = reportTypeController.GetReportTypeWithID(reportTypeLast.ReportTypeID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <ReportType> Ret = jsonRet as OkNegotiatedContentResult <ReportType>; ReportType reportTypeRet = Ret.Content; Assert.AreEqual(reportTypeLast.ReportTypeID, reportTypeRet.ReportTypeID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Post to return CSSPError because ReportTypeID exist IHttpActionResult jsonRet2 = reportTypeController.Post(reportTypeRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <ReportType> reportTypeRet2 = jsonRet2 as OkNegotiatedContentResult <ReportType>; Assert.IsNull(reportTypeRet2); BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult; Assert.IsNotNull(badRequest2); // Post to return newly added ReportType reportTypeRet.ReportTypeID = 0; reportTypeController.Request = new System.Net.Http.HttpRequestMessage(); reportTypeController.Request.RequestUri = new System.Uri("http://localhost:5000/api/reportType"); IHttpActionResult jsonRet3 = reportTypeController.Post(reportTypeRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet3); CreatedNegotiatedContentResult <ReportType> reportTypeRet3 = jsonRet3 as CreatedNegotiatedContentResult <ReportType>; Assert.IsNotNull(reportTypeRet3); BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult; Assert.IsNull(badRequest3); IHttpActionResult jsonRet4 = reportTypeController.Delete(reportTypeRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet4); OkNegotiatedContentResult <ReportType> reportTypeRet4 = jsonRet4 as OkNegotiatedContentResult <ReportType>; Assert.IsNotNull(reportTypeRet4); BadRequestErrorMessageResult badRequest4 = jsonRet4 as BadRequestErrorMessageResult; Assert.IsNull(badRequest4); } } }
public void ReportType_Controller_GetReportTypeList_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { ReportTypeController reportTypeController = new ReportTypeController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(reportTypeController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, reportTypeController.DatabaseType); ReportType reportTypeFirst = new ReportType(); int count = -1; Query query = new Query(); using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { ReportTypeService reportTypeService = new ReportTypeService(query, db, ContactID); reportTypeFirst = (from c in db.ReportTypes select c).FirstOrDefault(); count = (from c in db.ReportTypes select c).Count(); count = (query.Take > count ? count : query.Take); } // ok with ReportType info IHttpActionResult jsonRet = reportTypeController.GetReportTypeList(); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <List <ReportType> > ret = jsonRet as OkNegotiatedContentResult <List <ReportType> >; Assert.AreEqual(reportTypeFirst.ReportTypeID, ret.Content[0].ReportTypeID); Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count); List <ReportType> reportTypeList = new List <ReportType>(); count = -1; query = new Query(); using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { ReportTypeService reportTypeService = new ReportTypeService(query, db, ContactID); reportTypeList = (from c in db.ReportTypes select c).OrderBy(c => c.ReportTypeID).Skip(0).Take(2).ToList(); count = (from c in db.ReportTypes select c).Count(); } if (count > 0) { query.Skip = 0; query.Take = 5; count = (query.Take > count ? query.Take : count); // ok with ReportType info jsonRet = reportTypeController.GetReportTypeList(query.Language.ToString(), query.Skip, query.Take); Assert.IsNotNull(jsonRet); ret = jsonRet as OkNegotiatedContentResult <List <ReportType> >; Assert.AreEqual(reportTypeList[0].ReportTypeID, ret.Content[0].ReportTypeID); 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 ReportType info IHttpActionResult jsonRet2 = reportTypeController.GetReportTypeList(query.Language.ToString(), query.Skip, query.Take); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <List <ReportType> > ret2 = jsonRet2 as OkNegotiatedContentResult <List <ReportType> >; Assert.AreEqual(reportTypeList[1].ReportTypeID, ret2.Content[0].ReportTypeID); Assert.AreEqual((count > query.Take ? query.Take : count), ret2.Content.Count); } } } } }
public IHttpActionResult GetReportTypeList([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)) { ReportTypeService reportTypeService = new ReportTypeService(new Query() { Lang = lang }, db, ContactID); if (extra == "A") // QueryString contains [extra=A] { reportTypeService.Query = reportTypeService.FillQuery(typeof(ReportTypeExtraA), lang, skip, take, asc, desc, where, extra); if (reportTypeService.Query.HasErrors) { return(Ok(new List <ReportTypeExtraA>() { new ReportTypeExtraA() { HasErrors = reportTypeService.Query.HasErrors, ValidationResults = reportTypeService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(reportTypeService.GetReportTypeExtraAList().ToList())); } } else if (extra == "B") // QueryString contains [extra=B] { reportTypeService.Query = reportTypeService.FillQuery(typeof(ReportTypeExtraB), lang, skip, take, asc, desc, where, extra); if (reportTypeService.Query.HasErrors) { return(Ok(new List <ReportTypeExtraB>() { new ReportTypeExtraB() { HasErrors = reportTypeService.Query.HasErrors, ValidationResults = reportTypeService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(reportTypeService.GetReportTypeExtraBList().ToList())); } } else // QueryString has no parameter [extra] or extra is empty { reportTypeService.Query = reportTypeService.FillQuery(typeof(ReportType), lang, skip, take, asc, desc, where, extra); if (reportTypeService.Query.HasErrors) { return(Ok(new List <ReportType>() { new ReportType() { HasErrors = reportTypeService.Query.HasErrors, ValidationResults = reportTypeService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(reportTypeService.GetReportTypeList().ToList())); } } } }
public void ReportType_Properties_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { ReportTypeService reportTypeService = new ReportTypeService(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 = reportTypeService.GetReportTypeList().Count(); ReportType reportType = GetFilledRandomReportType(""); // ------------------------------- // ------------------------------- // Properties testing // ------------------------------- // ------------------------------- // ----------------------------------- // [Key] // Is NOT Nullable // reportType.ReportTypeID (Int32) // ----------------------------------- reportType = null; reportType = GetFilledRandomReportType(""); reportType.ReportTypeID = 0; reportTypeService.Update(reportType); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "ReportTypeID"), reportType.ValidationResults.FirstOrDefault().ErrorMessage); reportType = null; reportType = GetFilledRandomReportType(""); reportType.ReportTypeID = 10000000; reportTypeService.Update(reportType); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "ReportType", "ReportTypeID", reportType.ReportTypeID.ToString()), reportType.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPEnumType] // reportType.TVType (TVTypeEnum) // ----------------------------------- reportType = null; reportType = GetFilledRandomReportType(""); reportType.TVType = (TVTypeEnum)1000000; reportTypeService.Add(reportType); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "TVType"), reportType.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPEnumType] // reportType.FileType (FileTypeEnum) // ----------------------------------- reportType = null; reportType = GetFilledRandomReportType(""); reportType.FileType = (FileTypeEnum)1000000; reportTypeService.Add(reportType); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "FileType"), reportType.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [StringLength(100))] // reportType.UniqueCode (String) // ----------------------------------- reportType = null; reportType = GetFilledRandomReportType("UniqueCode"); Assert.AreEqual(false, reportTypeService.Add(reportType)); Assert.AreEqual(1, reportType.ValidationResults.Count()); Assert.IsTrue(reportType.ValidationResults.Where(c => c.ErrorMessage == string.Format(CSSPServicesRes._IsRequired, "UniqueCode")).Any()); Assert.AreEqual(null, reportType.UniqueCode); Assert.AreEqual(count, reportTypeService.GetReportTypeList().Count()); reportType = null; reportType = GetFilledRandomReportType(""); reportType.UniqueCode = GetRandomString("", 101); Assert.AreEqual(false, reportTypeService.Add(reportType)); Assert.AreEqual(string.Format(CSSPServicesRes._MaxLengthIs_, "UniqueCode", "100"), reportType.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, reportTypeService.GetReportTypeList().Count()); // ----------------------------------- // Is Nullable // [CSSPEnumType] // reportType.Language (LanguageEnum) // ----------------------------------- reportType = null; reportType = GetFilledRandomReportType(""); reportType.Language = (LanguageEnum)1000000; reportTypeService.Add(reportType); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "Language"), reportType.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is Nullable // [StringLength(100))] // reportType.Name (String) // ----------------------------------- reportType = null; reportType = GetFilledRandomReportType(""); reportType.Name = GetRandomString("", 101); Assert.AreEqual(false, reportTypeService.Add(reportType)); Assert.AreEqual(string.Format(CSSPServicesRes._MaxLengthIs_, "Name", "100"), reportType.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, reportTypeService.GetReportTypeList().Count()); // ----------------------------------- // Is Nullable // [StringLength(1000))] // reportType.Description (String) // ----------------------------------- reportType = null; reportType = GetFilledRandomReportType(""); reportType.Description = GetRandomString("", 1001); Assert.AreEqual(false, reportTypeService.Add(reportType)); Assert.AreEqual(string.Format(CSSPServicesRes._MaxLengthIs_, "Description", "1000"), reportType.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, reportTypeService.GetReportTypeList().Count()); // ----------------------------------- // Is Nullable // [StringLength(100))] // reportType.StartOfFileName (String) // ----------------------------------- reportType = null; reportType = GetFilledRandomReportType(""); reportType.StartOfFileName = GetRandomString("", 101); Assert.AreEqual(false, reportTypeService.Add(reportType)); Assert.AreEqual(string.Format(CSSPServicesRes._MaxLengthIs_, "StartOfFileName", "100"), reportType.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, reportTypeService.GetReportTypeList().Count()); // ----------------------------------- // Is NOT Nullable // [CSSPAfter(Year = 1980)] // reportType.LastUpdateDate_UTC (DateTime) // ----------------------------------- reportType = null; reportType = GetFilledRandomReportType(""); reportType.LastUpdateDate_UTC = new DateTime(); reportTypeService.Add(reportType); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "LastUpdateDate_UTC"), reportType.ValidationResults.FirstOrDefault().ErrorMessage); reportType = null; reportType = GetFilledRandomReportType(""); reportType.LastUpdateDate_UTC = new DateTime(1979, 1, 1); reportTypeService.Add(reportType); Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "LastUpdateDate_UTC", "1980"), reportType.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = Contact)] // reportType.LastUpdateContactTVItemID (Int32) // ----------------------------------- reportType = null; reportType = GetFilledRandomReportType(""); reportType.LastUpdateContactTVItemID = 0; reportTypeService.Add(reportType); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "LastUpdateContactTVItemID", reportType.LastUpdateContactTVItemID.ToString()), reportType.ValidationResults.FirstOrDefault().ErrorMessage); reportType = null; reportType = GetFilledRandomReportType(""); reportType.LastUpdateContactTVItemID = 1; reportTypeService.Add(reportType); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "LastUpdateContactTVItemID", "Contact"), reportType.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [NotMapped] // reportType.HasErrors (Boolean) // ----------------------------------- // No testing requied // ----------------------------------- // Is NOT Nullable // [NotMapped] // reportType.ValidationResults (IEnumerable`1) // ----------------------------------- // No testing requied } } }