Exemplo n.º 1
0
        public void EditGroupRename()
        {
            string pageTypeID = "16";

            PageType page = _wvm.PageList.FirstOrDefault(x => x.PageTypeID.Equals(pageTypeID));
            ObservableCollection <GroupTypeOrder> groups = page.GroupTypeOrders;
            GroupTypeOrder renameGroup = groups[0];

            List <string> departments = new List <string>();

            departments.Add("-1");
            string engTransText = "Rename group";
            string danTransText = "Omdøb gruppe";

            _groupTableVm.GroupTypeOrderCollection = groups;

            _groupTableVm.EditGroup(renameGroup, engTransText, danTransText, departments);

            //Export to excel with the group in it
            _exExcel.CreateNewExcel(_exportPath);

            //Import the new excel file
            _impExcel.ImportExcelConfiguration(_exportPath);

            #region ktResources tests

            //Get the new groups in ktResources
            List <ktResources> resources =
                _impExcel._workSheetktResources.ktResourceList.Where(
                    x => x.ResourceResxID.Equals("InfectionFactors")).ToList();

            //Check if there only is one item of "New Group" in ktResources
            Assert.AreEqual(resources.Count(), 1);
            ktResources newResource = resources[0];

            //Check if new group has a ResourceTypeID equal to 1.
            //Means that the group is a group
            Assert.AreEqual(newResource.ResourceTypeID, "1");

            //Does the old list contain the new groups?
            CollectionAssert.DoesNotContain(_oldResources, newResource);

            #endregion

            #region ktUIResourceTranslation tests

            //Get the new groups in ktResourceTranslation
            List <ktResourceTranslation> resourceTranslations =
                _impExcel._workSheetktResourceTranslation.ktResourceTranslationList.Where(
                    x => x.ResourceID.Equals(newResource.ResourceID)).ToList();

            //Check if there are four items of "New Group" in ktResourceTranslation
            Assert.AreEqual(resourceTranslations.Count(), 2);

            //Check if the translation texts are right for the two "New Groups"
            foreach (ktResourceTranslation rt in resourceTranslations)
            {
                if (rt.LanguageID.Equals("1"))
                {
                    Assert.AreEqual(rt.TranslationText, engTransText);
                }
                else
                {
                    Assert.AreEqual(rt.TranslationText, danTransText);
                }

                //Does the "New Group" exist in the old list
                CollectionAssert.DoesNotContain(_oldResTranslation, rt);
            }

            #endregion
        }