Beispiel #1
0
 public static DictionaryNodeOptions GetWsOptionsForLanguages(string[] languages, DictionaryNodeWritingSystemOptions.WritingSystemType type)
 {
     return(new DictionaryNodeWritingSystemOptions
     {
         Options = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(languages),
         WsType = type
     });
 }
Beispiel #2
0
        public static DictionaryNodeOptions GetListOptionsForStrings(DictionaryNodeListOptions.ListIds listName, IEnumerable <string> checkedItems)
        {
            var listOptions = new DictionaryNodeListOptions
            {
                ListId  = listName,
                Options = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(checkedItems)
            };

            return(listOptions);
        }
Beispiel #3
0
        public static DictionaryNodeOptions GetListOptionsForItems(DictionaryNodeListOptions.ListIds listName, ICmPossibility[] checkedItems)
        {
            var listOptions = new DictionaryNodeListOptions
            {
                ListId  = listName,
                Options = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(checkedItems.Select(id => id.Guid.ToString()).ToList())
            };

            return(listOptions);
        }
Beispiel #4
0
 public static DictionaryNodeOptions GetWsOptionsForLanguageswithDisplayWsAbbrev(string[] languages,
                                                                                 DictionaryNodeWritingSystemOptions.WritingSystemType type = 0)
 {
     return(new DictionaryNodeWritingSystemOptions
     {
         Options = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(languages),
         DisplayWritingSystemAbbreviations = true,
         WsType = type
     });
 }
        public void UploadToWebonaryExportsXhtmlAndCss()
        {
            using (var controller = SetUpController())
            {
                var mockView   = SetUpView();
                var testConfig = new Dictionary <string, DictionaryConfigurationModel>();
                mockView.Model.Configurations = testConfig;
                // Build model sufficient to generate xhtml and css
                ConfiguredXHTMLGenerator.AssemblyFile = "FDO";
                var mainHeadwordNode = new ConfigurableDictionaryNode
                {
                    FieldDescription      = "HeadWord",
                    CSSClassNameOverride  = "entry",
                    DictionaryNodeOptions = new DictionaryNodeWritingSystemOptions {
                        Options = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(new[] { "fr" })
                    },
                    Before = "MainEntry: ",
                };
                var mainEntryNode = new ConfigurableDictionaryNode
                {
                    Children = new List <ConfigurableDictionaryNode> {
                        mainHeadwordNode
                    },
                    FieldDescription = "LexEntry",
                };
                var model = new DictionaryConfigurationModel {
                    Parts = new List <ConfigurableDictionaryNode> {
                        mainEntryNode
                    }
                };
                CssGeneratorTests.PopulateFieldsForTesting(model);
                testConfig["Test Config"] = model;
                // create entry sufficient to generate xhtml and css
                var factory = Cache.ServiceLocator.GetInstance <ILexEntryFactory>();
                var entry   = factory.Create();
                var wsFr    = Cache.WritingSystemFactory.GetWsFromStr("fr");
                entry.CitationForm.set_String(wsFr, Cache.TsStrFactory.MakeString("Headword", wsFr));
                //SUT
                Assert.DoesNotThrow(() => controller.UploadToWebonary(mockView.Model, mockView));

                // The names of the files being sent to webonary are listed while logging the zip
                Assert.That(mockView.StatusStrings.Any(s => s.Contains("configured.xhtml")), "xhtml not logged as compressed");
                Assert.That(mockView.StatusStrings.Any(s => s.Contains("configured.css")), "css not logged as compressed");
            }
        }
Beispiel #6
0
        public static DictionaryNodeOptions GetFullyEnabledListOptions(LcmCache cache, DictionaryNodeListOptions.ListIds listName)
        {
            List <DictionaryNodeListOptions.DictionaryNodeOption> dnoList;
            var useParaOptions = false;

            switch (listName)
            {
            case DictionaryNodeListOptions.ListIds.Minor:
                dnoList = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(
                    new[] { XmlViewsUtils.GetGuidForUnspecifiedVariantType(), XmlViewsUtils.GetGuidForUnspecifiedComplexFormType() }
                    .Select(guid => guid.ToString())
                    .Union(cache.LangProject.LexDbOA.ComplexEntryTypesOA.PossibilitiesOS
                           .Union(cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS).Select(item => item.Guid.ToString())));
                break;

            case DictionaryNodeListOptions.ListIds.Variant:
                dnoList = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(
                    new[] { XmlViewsUtils.GetGuidForUnspecifiedVariantType().ToString() }
                    .Union(cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Select(item => item.Guid.ToString())));
                break;

            case DictionaryNodeListOptions.ListIds.Complex:
                useParaOptions = true;
                dnoList        = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(
                    new[] { XmlViewsUtils.GetGuidForUnspecifiedComplexFormType().ToString() }
                    .Union(cache.LangProject.LexDbOA.ComplexEntryTypesOA.PossibilitiesOS.Select(item => item.Guid.ToString())));
                break;

            case DictionaryNodeListOptions.ListIds.Note:
                useParaOptions = true;
                dnoList        = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(
                    new[] { XmlViewsUtils.GetGuidForUnspecifiedExtendedNoteType().ToString() }
                    .Union(cache.LangProject.LexDbOA.ExtendedNoteTypesOA.PossibilitiesOS.Select(item => item.Guid.ToString())));
                break;

            default:
                throw new NotImplementedException(string.Format("Unknown list id {0}", listName));
            }

            DictionaryNodeListOptions listOptions = useParaOptions ? new DictionaryNodeListAndParaOptions() : new DictionaryNodeListOptions();

            listOptions.ListId  = listName;
            listOptions.Options = dnoList;
            return(listOptions);
        }
Beispiel #7
0
        public void UploadToWebonaryExportsXhtmlAndCss()
        {
            using (var controller = SetUpController())
            {
                var mockView       = SetUpView();
                var testConfig     = new Dictionary <string, DictionaryConfigurationModel>();
                var reversalConfig = new Dictionary <string, DictionaryConfigurationModel>();
                mockView.Model.Configurations = testConfig;
                mockView.Model.Reversals      = reversalConfig;
                // Build model sufficient to generate xhtml and css
                ConfiguredXHTMLGenerator.AssemblyFile = "SIL.LCModel";
                var mainHeadwordNode = new ConfigurableDictionaryNode
                {
                    FieldDescription      = "HeadWord",
                    CSSClassNameOverride  = "entry",
                    DictionaryNodeOptions = new DictionaryNodeWritingSystemOptions {
                        Options = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(new[] { "fr" })
                    },
                    Before = "MainEntry: ",
                };
                var mainEntryNode = new ConfigurableDictionaryNode
                {
                    Children = new List <ConfigurableDictionaryNode> {
                        mainHeadwordNode
                    },
                    FieldDescription = "LexEntry",
                };
                var model = new DictionaryConfigurationModel {
                    Parts = new List <ConfigurableDictionaryNode> {
                        mainEntryNode
                    }
                };
                CssGeneratorTests.PopulateFieldsForTesting(model);
                testConfig["Test Config"] = model;

                var reversalFormNode = new ConfigurableDictionaryNode
                {
                    FieldDescription = "ReversalForm",
                    //DictionaryNodeOptions = CXGTests.GetWsOptionsForLanguages(new[] { "en" }),
                    DictionaryNodeOptions = new DictionaryNodeWritingSystemOptions
                    {
                        WsType  = DictionaryNodeWritingSystemOptions.WritingSystemType.Reversal,
                        Options = new List <DictionaryNodeListOptions.DictionaryNodeOption>
                        {
                            new DictionaryNodeListOptions.DictionaryNodeOption {
                                Id = "en"
                            }
                        },
                        DisplayWritingSystemAbbreviations = false
                    },
                    Label = "Reversal Form"
                };
                var reversalEntryNode = new ConfigurableDictionaryNode
                {
                    Children = new List <ConfigurableDictionaryNode> {
                        reversalFormNode
                    },
                    FieldDescription = "ReversalIndexEntry"
                };
                model = new DictionaryConfigurationModel {
                    Parts = new List <ConfigurableDictionaryNode> {
                        reversalEntryNode
                    }
                };
                CssGeneratorTests.PopulateFieldsForTesting(model);
                reversalConfig["English"] = model;
                model.Label         = "English";
                model.WritingSystem = "en";
                List <string> reversalLanguage = new List <string>();
                reversalLanguage.Add("English");
                mockView.Model.SelectedReversals = reversalLanguage;

                // create entry sufficient to generate xhtml and css
                var factory = Cache.ServiceLocator.GetInstance <ILexEntryFactory>();
                var entry   = factory.Create();
                var wsFr    = Cache.WritingSystemFactory.GetWsFromStr("fr");
                entry.CitationForm.set_String(wsFr, TsStringUtils.MakeString("Headword", wsFr));
                //SUT
                Assert.DoesNotThrow(() => controller.UploadToWebonary(mockView.Model, mockView));

                // The names of the files being sent to webonary are listed while logging the zip
                Assert.That(mockView.StatusStrings.Any(s => s.Contains("configured.xhtml")), "xhtml not logged as compressed");
                Assert.That(mockView.StatusStrings.Any(s => s.Contains("configured.css")), "css not logged as compressed");
                Assert.That(mockView.StatusStrings.Any(s => s.Contains("reversal_en.xhtml")), "reversal_enxhtml not logged as compressed");
                Assert.That(mockView.StatusStrings.Any(s => s.Contains("Exporting entries for English reversal")), "English reversal not exported");
            }
        }