public void MWQMPlanController__MWQMPlanByProvince_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture, controllerAction);

                using (TransactionScope ts = new TransactionScope())
                {
                    RetAddMWQMPlan retAddMWQMPlan = AddMWQMPlanAndSubElements((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en));

                    string Q = "!View/" + retAddMWQMPlan.TVItemModelNB.TVText + "|||" + retAddMWQMPlan.TVItemModelNB.TVItemID;

                    PartialViewResult partialViewResult = controller._MWQMPlanByProvince(Q) as PartialViewResult;
                    Assert.IsNotNull(partialViewResult);

                    URLModel URLModelRet = (URLModel)partialViewResult.ViewBag.URLModel;
                    Assert.AreEqual(retAddMWQMPlan.TVItemModelNB.TVItemID, URLModelRet.TVItemIDList[0]);

                    List <ContactModel> AdminContactModelListRet = (List <ContactModel>)partialViewResult.ViewBag.AdminContactModelList;
                    Assert.IsNull(AdminContactModelListRet); // because IsMWQMPlanner == true

                    bool IsShowMap = (bool)partialViewResult.ViewBag.IsShowMap;
                    Assert.IsFalse(IsShowMap);

                    bool IsMWQMPlannerRet = (bool)partialViewResult.ViewBag.IsMWQMPlanner;
                    Assert.IsTrue(IsMWQMPlannerRet);

                    List <MWQMPlanAndFilesLabSheetCountModel> MWQMPlanAndFilesLabSheetCountModelListRet = (List <MWQMPlanAndFilesLabSheetCountModel>)partialViewResult.ViewBag.MWQMPlanAndFilesLabSheetCountModelList;
                    Assert.IsTrue(MWQMPlanAndFilesLabSheetCountModelListRet.Count > 1);

                    List <AppTaskModel> AppTaskModelListRet = (List <AppTaskModel>)partialViewResult.ViewBag.AppTaskModelList;
                    Assert.IsTrue(AppTaskModelListRet.Count == 0);
                }
            }
        }
        public void MWQMPlanController__MWQMPlanAddOrModify_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture, controllerAction);

                using (TransactionScope ts = new TransactionScope())
                {
                    RetAddMWQMPlan retAddMWQMPlan = AddMWQMPlanAndSubElements((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en));

                    PartialViewResult partialViewResult = controller._MWQMPlanAddOrModify(retAddMWQMPlan.TVItemModelNB.TVItemID, retAddMWQMPlan.MWQMPlanModel.MWQMPlanID) as PartialViewResult;
                    Assert.IsNotNull(partialViewResult);

                    MWQMPlanController mwqmPlanController = (MWQMPlanController)partialViewResult.ViewBag.MWQMPlanController;
                    Assert.IsNotNull(mwqmPlanController);

                    int ProvinceTVItemIDRet = (int)partialViewResult.ViewBag.ProvinceTVItemID;
                    Assert.AreEqual(retAddMWQMPlan.TVItemModelNB.TVItemID, ProvinceTVItemIDRet);

                    int MWQMPlanIDRet = (int)partialViewResult.ViewBag.MWQMPlanID;
                    Assert.AreEqual(retAddMWQMPlan.MWQMPlanModel.MWQMPlanID, MWQMPlanIDRet);

                    MWQMPlanModel MWQMPlanModelRet = (MWQMPlanModel)partialViewResult.ViewBag.MWQMPlanModel;
                    Assert.IsNotNull(MWQMPlanModelRet);
                    Assert.AreEqual(retAddMWQMPlan.MWQMPlanModel.MWQMPlanID, MWQMPlanModelRet.MWQMPlanID);

                    List <MWQMPlanSubsectorModel> MWQMPlanSubsectorModelListRet = (List <MWQMPlanSubsectorModel>)partialViewResult.ViewBag.MWQMPlanSubsectorModelList;
                    Assert.IsTrue(MWQMPlanSubsectorModelListRet.Count == 1);

                    List <ContactModel> AdminContactModelListRet = (List <ContactModel>)partialViewResult.ViewBag.AdminContactModelList;
                    Assert.IsNull(AdminContactModelListRet); // because IsMWQMPlanner == true

                    ContactModel ContactModelRet = (ContactModel)partialViewResult.ViewBag.ContactModel;
                    Assert.IsNotNull(ContactModelRet);
                    Assert.AreEqual(contactModelListGood[0].ContactTVItemID, ContactModelRet.ContactTVItemID);

                    List <TVItemModel> TVItemModelSubsectorListRet = (List <TVItemModel>)partialViewResult.ViewBag.TVItemModelSubsectorList;
                    Assert.IsTrue(TVItemModelSubsectorListRet.Count > 0);

                    List <SampleTypeEnumTextOrdered> SampleTypeEnumTextOrderedListRet = (List <SampleTypeEnumTextOrdered>)partialViewResult.ViewBag.SampleTypeEnumTextOrderedList;
                    Assert.IsTrue(SampleTypeEnumTextOrderedListRet.Count > 0);

                    SampleTypeEnumTextOrdered SampleTypeEnumTextOrderedFirstRet = (SampleTypeEnumTextOrdered)partialViewResult.ViewBag.SampleTypeEnumTextOrderedFirst;
                    Assert.IsNotNull(SampleTypeEnumTextOrderedFirstRet);
                    Assert.AreEqual(SampleTypeEnum.Routine, SampleTypeEnumTextOrderedFirstRet.SampleType);

                    bool IsMWQMPlannerRet = (bool)partialViewResult.ViewBag.IsMWQMPlanner;
                    Assert.IsTrue(IsMWQMPlannerRet);
                }
            }
        }
        public void MWQMPlanController__MWQMPlanMWQMSites_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture, controllerAction);

                using (TransactionScope ts = new TransactionScope())
                {
                    RetAddMWQMPlan retAddMWQMPlan = AddMWQMPlanAndSubElements((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en));

                    PartialViewResult partialViewResult = controller._MWQMPlanMWQMSites(retAddMWQMPlan.MWQMPlanModel.MWQMPlanID, retAddMWQMPlan.TVItemModelNB.TVItemID, retAddMWQMPlan.TVItemModelSS.TVItemID) as PartialViewResult;
                    Assert.IsNotNull(partialViewResult);

                    int MWQMPlanIDRet = (int)partialViewResult.ViewBag.MWQMPlanID;
                    Assert.AreEqual(retAddMWQMPlan.MWQMPlanModel.MWQMPlanID, MWQMPlanIDRet);

                    int ProvinceTVItemIDRet = (int)partialViewResult.ViewBag.ProvinceTVItemID;
                    Assert.AreEqual(retAddMWQMPlan.TVItemModelNB.TVItemID, ProvinceTVItemIDRet);

                    int SubsectorTVItemIDRet = (int)partialViewResult.ViewBag.SubsectorTVItemID;
                    Assert.AreEqual(retAddMWQMPlan.TVItemModelSS.TVItemID, SubsectorTVItemIDRet);

                    List <MWQMPlanSubsectorSiteModel> MWQMPlanSubsectorSiteModelListRet = (List <MWQMPlanSubsectorSiteModel>)partialViewResult.ViewBag.MWQMPlanSubsectorSiteModelList;
                    Assert.IsTrue(MWQMPlanSubsectorSiteModelListRet.Count == 1);

                    List <TVItemModel> TVItemModelMWQMSiteListRet = (List <TVItemModel>)partialViewResult.ViewBag.TVItemModelMWQMSiteList;
                    Assert.IsTrue(TVItemModelMWQMSiteListRet.Count > 0);

                    List <ContactModel> AdminContactModelListRet = (List <ContactModel>)partialViewResult.ViewBag.AdminContactModelList;
                    Assert.IsNull(AdminContactModelListRet); // because IsMWQMPlanner == true

                    bool IsMWQMPlannerRet = (bool)partialViewResult.ViewBag.IsMWQMPlanner;
                    Assert.IsTrue(IsMWQMPlannerRet);

                    ContactModel ContactModelRet = (ContactModel)partialViewResult.ViewBag.ContactModel;
                    Assert.IsNotNull(ContactModelRet);
                    Assert.AreEqual(contactModelListGood[0].ContactTVItemID, ContactModelRet.ContactTVItemID);
                }
            }
        }
        private RetAddMWQMPlan AddMWQMPlanAndSubElements(LanguageEnum LanguageRequest)
        {
            TVItemModel tvItemModelRoot = tvItemService.GetRootTVItemModelDB();

            Assert.AreEqual("", tvItemModelRoot.Error);

            TVItemModel tvItemModelCanada = tvItemService.GetChildTVItemModelWithParentIDAndTVTextAndTVTypeDB(tvItemModelRoot.TVItemID, "Canada", TVTypeEnum.Country);

            Assert.AreEqual("", tvItemModelCanada.Error);

            TVItemModel tvItemModelNB = tvItemService.GetChildTVItemModelWithParentIDAndTVTextAndTVTypeDB(tvItemModelCanada.TVItemID, (LanguageRequest == LanguageEnum.fr ? "Nouveau-Brunswick" : "New Brunswick"), TVTypeEnum.Province);

            Assert.AreEqual("", tvItemModelNB.Error);

            List <TVItemModel> tvItemModelSSList = tvItemService.GetChildrenTVItemModelListWithTVItemIDAndTVTypeDB(tvItemModelNB.TVItemID, TVTypeEnum.Subsector);

            Assert.IsTrue(tvItemModelSSList.Where(c => c.TVText.StartsWith("NB-06-020-002")).Any());

            TVItemModel tvItemModelSS = tvItemModelSSList.Where(c => c.TVText.StartsWith("NB-06-020-002")).FirstOrDefault();

            Assert.IsTrue(tvItemModelSS.TVText.StartsWith("NB-06-020-002"));

            MWQMPlanModel mwqmPlanModelNew = new MWQMPlanModel()
            {
                ConfigFileName   = "UniqueConfigFileName",
                ForGroupName     = "UniqueGroupName",
                SampleType       = SampleTypeEnum.Routine,
                ProvinceTVItemID = tvItemModelNB.TVItemID,
                CreatorTVItemID  = contactModelListGood[0].ContactTVItemID,
                Year             = 2015,
                SecretCode       = "abcdef",
                DailyDuplicatePrecisionCriteria     = 0.6872f,
                IntertechDuplicatePrecisionCriteria = 0.093f,
                ConfigFileTxtTVItemID = null,
            };

            MWQMPlanModel mwqmPlanModelRet = mwqmPlanService.PostAddMWQMPlanDB(mwqmPlanModelNew);

            Assert.AreEqual("", mwqmPlanModelRet.Error);

            MWQMPlanSubsectorModel mwqmPlanSubsectorModelNew = new MWQMPlanSubsectorModel()
            {
                MWQMPlanID        = mwqmPlanModelRet.MWQMPlanID,
                SubsectorTVItemID = tvItemModelSS.TVItemID,
            };

            MWQMPlanSubsectorModel mwqmPlanSubsectorModelRet = mwqmPlanSubsectorService.PostAddMWQMPlanSubsectorDB(mwqmPlanSubsectorModelNew);

            Assert.AreEqual("", mwqmPlanSubsectorModelRet.Error);

            TVItemModel tvItemModelMWQMSite = tvItemService.GetChildrenTVItemModelListWithTVItemIDAndTVTypeDB(tvItemModelSS.TVItemID, TVTypeEnum.MWQMSite).FirstOrDefault();

            Assert.AreEqual(7460, tvItemModelMWQMSite.TVItemID);

            MWQMPlanSubsectorSiteModel mwqmPlanSubsectorSiteModel = new MWQMPlanSubsectorSiteModel()
            {
                MWQMPlanSubsectorID = mwqmPlanSubsectorModelRet.MWQMPlanSubsectorID,
                MWQMSiteTVItemID    = tvItemModelMWQMSite.TVItemID,
                IsDuplicate         = false
            };

            MWQMPlanSubsectorSiteModel mwqmPlanSubsectorSiteModelRet = mwqmPlanSubsectorSiteService.PostAddMWQMPlanSubsectorSiteDB(mwqmPlanSubsectorSiteModel);

            Assert.AreEqual("", mwqmPlanSubsectorSiteModelRet.Error);

            RetAddMWQMPlan retAddMWQMPlan = new RetAddMWQMPlan()
            {
                MWQMPlanModel = mwqmPlanModelRet,
                TVItemModelNB = tvItemModelNB,
                TVItemModelSS = tvItemModelSS
            };

            return(retAddMWQMPlan);
        }