public void VPScenarioLanguageService_PostUpdateVPScenarioLanguageDB_DoUpdateChanges_Error_Test() { foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture); using (TransactionScope ts = new TransactionScope()) { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); LanguageEnum LangToAdd = LanguageEnum.es; VPScenarioLanguageModel vpScenarioLanguageModelRet = AddVPScenarioLanguageModel(LangToAdd, vpScenarioModelRet); using (ShimsContext.Create()) { SetupShim(); FillVPScenarioLanguageModelUpdate(vpScenarioLanguageModelRet); string ErrorText = "ErrorText"; shimVPScenarioLanguageService.DoUpdateChanges = () => { return(ErrorText); }; VPScenarioLanguageModel vpScenarioLanguageModelRet2 = vpScenarioLanguageService.PostUpdateVPScenarioLanguageDB(vpScenarioLanguageModelRet); Assert.AreEqual(ErrorText, vpScenarioLanguageModelRet2.Error); } } } }
public VPResultModel AddVPResultModel() { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); if (!string.IsNullOrWhiteSpace(vpScenarioModelRet.Error)) { return(new VPResultModel() { Error = vpScenarioModelRet.Error }); } vpResultModelNew.VPScenarioID = vpScenarioModelRet.VPScenarioID; FillVPResultModel(vpResultModelNew); VPResultModel vpResultModelRet = vpResultService.PostAddVPResultDB(vpResultModelNew); if (!string.IsNullOrWhiteSpace(vpResultModelRet.Error)) { return(vpResultModelRet); } CompareVPResultModels(vpResultModelNew, vpResultModelRet); return(vpResultModelRet); }
public void VPScenarioLanguageService_FillVPScenarioLanguage_Test() { foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture); using (TransactionScope ts = new TransactionScope()) { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); LanguageEnum LangToAdd = LanguageEnum.es; FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModelRet, vpScenarioLanguageModelNew); ContactOK contactOK = vpScenarioLanguageService.IsContactOK(); string retStr = vpScenarioLanguageService.FillVPScenarioLanguage(vpScenarioLanguage, vpScenarioLanguageModelNew, contactOK); Assert.AreEqual("", retStr); Assert.AreEqual(contactOK.ContactTVItemID, vpScenarioLanguage.LastUpdateContactTVItemID); contactOK = null; retStr = vpScenarioLanguageService.FillVPScenarioLanguage(vpScenarioLanguage, vpScenarioLanguageModelNew, contactOK); Assert.AreEqual("", retStr); Assert.AreEqual(2, vpScenarioLanguage.LastUpdateContactTVItemID); } } }
public void VPScenarioLanguageService_PostDeleteVPScenarioLanguageDB_IsContactOK_Error_Test() { foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture); using (TransactionScope ts = new TransactionScope()) { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); LanguageEnum LangToAdd = LanguageEnum.es; VPScenarioLanguageModel vpScenarioLanguageModelRet = AddVPScenarioLanguageModel(LangToAdd, vpScenarioModelRet); VPScenarioLanguageModel vpScenarioLanguageModelRet2 = UpdateVPScenarioLanguageModel(vpScenarioLanguageModelRet); using (ShimsContext.Create()) { SetupShim(); string ErrorText = "ErrorText"; shimVPScenarioLanguageService.IsContactOK = () => { return(new ContactOK() { Error = ErrorText }); }; VPScenarioLanguageModel vpScenarioLanguageModelRet3 = vpScenarioLanguageService.PostDeleteVPScenarioLanguageDB(vpScenarioLanguageModelRet2.VPScenarioID, LangToAdd); Assert.AreEqual(ErrorText, vpScenarioLanguageModelRet3.Error); } } } }
public void VPScenarioLanguageService_PostUpdateVPScenarioLanguageDB_GetVPScenarioLanguageWithVPScenarioIDAndLanguageDB_Error_Test() { foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture); using (TransactionScope ts = new TransactionScope()) { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); LanguageEnum LangToAdd = LanguageEnum.es; VPScenarioLanguageModel vpScenarioLanguageModelRet = AddVPScenarioLanguageModel(LangToAdd, vpScenarioModelRet); using (ShimsContext.Create()) { SetupShim(); FillVPScenarioLanguageModelUpdate(vpScenarioLanguageModelRet); //string ErrorText = "ErrorText"; shimVPScenarioLanguageService.GetVPScenarioLanguageWithVPScenarioIDAndLanguageDBInt32LanguageEnum = (a, b) => { return(null); }; VPScenarioLanguageModel vpScenarioLanguageModelRet2 = vpScenarioLanguageService.PostUpdateVPScenarioLanguageDB(vpScenarioLanguageModelRet); Assert.AreEqual(string.Format(ServiceRes.CouldNotFind_ToUpdate, ServiceRes.VPScenarioLanguage), vpScenarioLanguageModelRet2.Error); } } } }
public void VPScenarioLanguageService_PostAddVPScenarioLanguageDB_Add_Error_Test() { foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture); using (TransactionScope ts = new TransactionScope()) { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); using (ShimsContext.Create()) { SetupShim(); LanguageEnum LangToAdd = LanguageEnum.es; FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModelRet, vpScenarioLanguageModelNew); //string ErrorText = "ErrorText"; shimVPScenarioLanguageService.FillVPScenarioLanguageVPScenarioLanguageVPScenarioLanguageModelContactOK = (a, b, c) => { return(""); }; VPScenarioLanguageModel vpScenarioLanguageModelRet = vpScenarioLanguageService.PostAddVPScenarioLanguageDB(vpScenarioLanguageModelNew); Assert.IsTrue(vpScenarioLanguageModelRet.Error.StartsWith(string.Format(ServiceRes.CouldNotAddError_, "").Substring(0, 10))); } } } }
public void VPScenarioLanguageService_PostAddVPScenarioLanguageDB_VPScenarioModelOK_Error_Test() { foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture); using (TransactionScope ts = new TransactionScope()) { using (ShimsContext.Create()) { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); LanguageEnum LangToAdd = LanguageEnum.es; FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModelRet, vpScenarioLanguageModelNew); string ErrorText = "ErrorText"; ShimVPScenarioLanguageService shimVPScenarioLanguageService = new ShimVPScenarioLanguageService(vpScenarioLanguageService); shimVPScenarioLanguageService.VPScenarioLanguageModelOKVPScenarioLanguageModel = (a) => { return(ErrorText); }; VPScenarioLanguageModel vpScenarioLanguageModelRet = vpScenarioLanguageService.PostAddVPScenarioLanguageDB(vpScenarioLanguageModelNew); Assert.AreEqual(ErrorText, vpScenarioLanguageModelRet.Error); } } } }
public JsonResult DeleteVPScenarioJSON(int VPScenarioID) { VPScenarioModel vpScenarioModelRet = _VPScenarioService.PostDeleteVPScenarioDB(VPScenarioID); // if ErrorOrSuccess == "" then successful otherwise contains error message return(Json(vpScenarioModelRet.Error, JsonRequestBehavior.AllowGet)); }
private void FillVPScenarioLanguageModelNew(LanguageEnum Language, VPScenarioModel vpScenarioModel, VPScenarioLanguageModel vpScenarioLanguageModel) { vpScenarioLanguageModel.VPScenarioID = vpScenarioModel.VPScenarioID; vpScenarioLanguageModel.VPScenarioName = randomService.RandomString("VPScenarioName", 30); vpScenarioLanguageModel.Language = Language; vpScenarioLanguageModel.TranslationStatus = TranslationStatusEnum.Translated; Assert.IsTrue(vpScenarioLanguageModel.VPScenarioID != 0); Assert.IsTrue(vpScenarioLanguageModel.VPScenarioName.Length == 30); Assert.IsTrue(vpScenarioLanguageModel.Language == Language); Assert.IsTrue(vpScenarioLanguageModel.TranslationStatus == TranslationStatusEnum.Translated); }
public JsonResult SaveVPScenarioRawResultsJSON(VPScenarioIDAndRawResults vpScenarioIDAndRawResults) { // used for the VPAuto Desktop application // anybody can get this information // No login required IPrincipal user = new GenericPrincipal(new GenericIdentity("*****@*****.**", "Forms"), null); VPScenarioService vpScenarioService = new VPScenarioService(LanguageEnum.en, user); //int VPScenarioID = int.Parse(uploadString.Substring(0, uploadString.IndexOf("|||"))); //string RawResults = uploadString.Substring(uploadString.IndexOf("|||") + 3); VPScenarioModel vpScenarioModel = vpScenarioService.PostSaveResultsInDB(vpScenarioIDAndRawResults.VPScenarioID, vpScenarioIDAndRawResults.RawResults); return(Json(vpScenarioModel.Error, JsonRequestBehavior.AllowGet)); }
public void VPScenarioLanguageService_GetVPScenarioModelCountDB_Test() { foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture); using (TransactionScope ts = new TransactionScope()) { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); LanguageEnum LangToAdd = LanguageEnum.es; VPScenarioLanguageModel vpScenarioModelLanguageRet = AddVPScenarioLanguageModel(LangToAdd, vpScenarioModelRet); int vpScenarioCount = vpScenarioLanguageService.GetVPScenarioLanguageModelCountDB(); Assert.AreEqual(testDBService.Count + 3, vpScenarioCount); } } }
public void VPScenarioLanguageService_GetVPScenarioLanguageWithVPScenarioIDAndLanguageDB_Test() { foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture); using (TransactionScope ts = new TransactionScope()) { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); LanguageEnum LangToAdd = LanguageEnum.es; VPScenarioLanguageModel vpScenarioLanguageModelRet = AddVPScenarioLanguageModel(LangToAdd, vpScenarioModelRet); VPScenarioLanguage vpScenarioLanguageRet2 = vpScenarioLanguageService.GetVPScenarioLanguageWithVPScenarioIDAndLanguageDB(vpScenarioLanguageModelRet.VPScenarioID, LangToAdd); Assert.AreEqual(vpScenarioLanguageModelRet.VPScenarioID, vpScenarioLanguageRet2.VPScenarioID); Assert.AreEqual(vpScenarioLanguageModelRet.Language, (LanguageEnum)vpScenarioLanguageRet2.Language); Assert.AreEqual(LangToAdd, (LanguageEnum)vpScenarioLanguageRet2.Language); } } }
public void VPScenarioLanguageService_PostAddVPScenarioLanguageDB_Good_Test() { foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture); using (TransactionScope ts = new TransactionScope()) { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); LanguageEnum LangToAdd = LanguageEnum.es; VPScenarioLanguageModel vpScenarioLanguageModelRet = AddVPScenarioLanguageModel(LangToAdd, vpScenarioModelRet); VPScenarioLanguageModel vpScenarioLanguageModelRet2 = UpdateVPScenarioLanguageModel(vpScenarioLanguageModelRet); VPScenarioLanguageModel vpScenarioLanguageModelRet3 = vpScenarioLanguageService.PostDeleteVPScenarioLanguageDB(vpScenarioLanguageModelRet2.VPScenarioID, LangToAdd); Assert.AreEqual("", vpScenarioLanguageModelRet3.Error); } } }
public void VPScenarioLanguageService_PostAddVPScenarioLanguageDB_UserEmailNotValidated_Test() { foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture); using (TransactionScope ts = new TransactionScope()) { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); LanguageEnum LangToAdd = LanguageEnum.es; ContactModel contactModelBad = contactModelListGood[2]; IPrincipal userBad = new GenericPrincipal(new GenericIdentity(contactModelBad.LoginEmail, "Forms"), null); vpScenarioLanguageService = new VPScenarioLanguageService((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en), userBad); VPScenarioLanguageModel vpScenarioLanguageModelRet = AddVPScenarioLanguageModel(LangToAdd, vpScenarioModelRet); Assert.AreEqual(ServiceRes.EmailRequiresValidation, vpScenarioLanguageModelRet.Error); } } }
public void VPScenarioLanguageService_VPScenarioLanguageModelOK_Test() { foreach (CultureInfo culture in setupData.cultureListGood) { SetupTest(contactModelListGood[0], culture); LanguageEnum LangToAdd = LanguageEnum.es; using (TransactionScope ts = new TransactionScope()) { VPScenarioModel vpScenarioModelRet = vpScenarioServiceTest.AddVPScenarioModel(); #region Good FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModelRet, vpScenarioLanguageModelNew); string retStr = vpScenarioLanguageService.VPScenarioLanguageModelOK(vpScenarioLanguageModelNew); Assert.AreEqual("", retStr); #endregion Good #region VPScenarioID FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModelRet, vpScenarioLanguageModelNew); vpScenarioLanguageModelNew.VPScenarioID = 0; retStr = vpScenarioLanguageService.VPScenarioLanguageModelOK(vpScenarioLanguageModelNew); Assert.AreEqual(string.Format(ServiceRes._IsRequired, ServiceRes.VPScenarioID), retStr); #endregion VPScenarioID #region Language int Min = 2; int Max = 2; FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModelRet, vpScenarioLanguageModelNew); vpScenarioLanguageModelNew.Language = (LanguageEnum)1000; retStr = vpScenarioLanguageService.VPScenarioLanguageModelOK(vpScenarioLanguageModelNew); Assert.AreEqual(string.Format(ServiceRes._IsRequired, ServiceRes.Language), retStr); FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModelRet, vpScenarioLanguageModelNew); vpScenarioLanguageModelNew.Language = LanguageEnum.en; retStr = vpScenarioLanguageService.VPScenarioLanguageModelOK(vpScenarioLanguageModelNew); Assert.AreEqual("", retStr); #endregion Language #region ScenarioName FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModelRet, vpScenarioLanguageModelNew); Min = 3; Max = 100; vpScenarioLanguageModelNew.VPScenarioName = randomService.RandomString("", Min - 1); retStr = vpScenarioLanguageService.VPScenarioLanguageModelOK(vpScenarioLanguageModelNew); Assert.AreEqual(string.Format(ServiceRes._MinLengthIs_, ServiceRes.VPScenarioName, Min), retStr); FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModelRet, vpScenarioLanguageModelNew); vpScenarioLanguageModelNew.VPScenarioName = randomService.RandomString("", Max + 1); retStr = vpScenarioLanguageService.VPScenarioLanguageModelOK(vpScenarioLanguageModelNew); Assert.AreEqual(string.Format(ServiceRes._MaxLengthIs_, ServiceRes.VPScenarioName, Max), retStr); FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModelRet, vpScenarioLanguageModelNew); vpScenarioLanguageModelNew.VPScenarioName = randomService.RandomString("", Max - 1); retStr = vpScenarioLanguageService.VPScenarioLanguageModelOK(vpScenarioLanguageModelNew); Assert.AreEqual("", retStr); FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModelRet, vpScenarioLanguageModelNew); vpScenarioLanguageModelNew.VPScenarioName = randomService.RandomString("", Max); retStr = vpScenarioLanguageService.VPScenarioLanguageModelOK(vpScenarioLanguageModelNew); Assert.AreEqual("", retStr); #endregion ScenarioName } } }
private VPScenarioLanguageModel AddVPScenarioLanguageModel(LanguageEnum LangToAdd, VPScenarioModel vpScenarioModel) { VPScenarioLanguageModel vpScenarioLanguageModelNew = new VPScenarioLanguageModel(); FillVPScenarioLanguageModelNew(LangToAdd, vpScenarioModel, vpScenarioLanguageModelNew); VPScenarioLanguageModel vpScenarioLanguagModelRet = vpScenarioLanguageService.PostAddVPScenarioLanguageDB(vpScenarioLanguageModelNew); if (!string.IsNullOrWhiteSpace(vpScenarioLanguagModelRet.Error)) { return(vpScenarioLanguagModelRet); } Assert.IsNotNull(vpScenarioLanguagModelRet); CompareVPScenarioLanguageModels(vpScenarioLanguageModelNew, vpScenarioLanguagModelRet); return(vpScenarioLanguagModelRet); }
public JsonResult CopyVPScenarioJSON(int VPScenarioID) { VPScenarioModel vpScenarioModel = _VPScenarioService.PostCopyVPScenarioDB(VPScenarioID); return(Json(vpScenarioModel.Error, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveVPScenarioJSON(FormCollection fc) { VPScenarioModel vpScenarioModel = _VPScenarioService.PostSaveVPScenarioDB(fc); return(Json(vpScenarioModel.Error, JsonRequestBehavior.AllowGet)); }
public JsonResult CreateNewVisualPlumeScenarioJSON(int InfrastructureTVItemID) { VPScenarioModel vpScenarioModel = _VPScenarioService.PostCreateNewVPScenarioDB(InfrastructureTVItemID); return(Json(vpScenarioModel.Error, JsonRequestBehavior.AllowGet)); }