Example #1
0
        public void CountDictionaryEntries_StemBasedConfigCountsHiddenMinorEntries(
            [Values(DictionaryConfigurationModel.ConfigType.Hybrid, DictionaryConfigurationModel.ConfigType.Lexeme)] DictionaryConfigurationModel.ConfigType configType)
        {
            var configModel  = ConfiguredXHTMLGeneratorTests.CreateInterestingConfigurationModel(Cache, null, configType);
            var mainEntry    = ConfiguredXHTMLGeneratorTests.CreateInterestingLexEntry(Cache);
            var complexEntry = ConfiguredXHTMLGeneratorTests.CreateInterestingLexEntry(Cache);
            var variantEntry = ConfiguredXHTMLGeneratorTests.CreateInterestingLexEntry(Cache);

            ConfiguredXHTMLGeneratorTests.CreateComplexForm(Cache, mainEntry, complexEntry, false);
            ConfiguredXHTMLGeneratorTests.CreateVariantForm(Cache, mainEntry, variantEntry, "Dialectal Variant");

            Assert.True(DictionaryExportService.IsGenerated(Cache, configModel, complexEntry.Hvo), "Should be generated once");
            Assert.True(DictionaryExportService.IsGenerated(Cache, configModel, variantEntry.Hvo), "Should be generated once");

            ConfiguredXHTMLGeneratorTests.SetPublishAsMinorEntry(complexEntry, false);
            ConfiguredXHTMLGeneratorTests.SetPublishAsMinorEntry(variantEntry, false);

            //SUT
            Assert.True(DictionaryExportService.IsGenerated(Cache, configModel, complexEntry.Hvo),
                        "Lexeme-based hidden minor entry should still be generated, because Complex Forms are Main Entries");
            Assert.False(DictionaryExportService.IsGenerated(Cache, configModel, variantEntry.Hvo),
                         "Lexeme-based hidden minor entry should not be generated, because Variants are always Minor Entries");
            Assert.True(DictionaryExportService.IsGenerated(Cache, configModel, mainEntry.Hvo), "Main entry should still be generated");

            var compoundGuid   = "1f6ae209-141a-40db-983c-bee93af0ca3c";
            var complexOptions = (DictionaryNodeListOptions)configModel.Parts[0].DictionaryNodeOptions;

            complexOptions.Options.First(option => option.Id == compoundGuid).IsEnabled = false;            // Compound
            Assert.False(DictionaryExportService.IsGenerated(Cache, configModel, complexEntry.Hvo), "Should not be generated");
        }
Example #2
0
        /// <summary>
        /// Creates a DictionaryConfigurationModel with one Main and one of each neeeded Minor Entry nodes, all with enabled HeadWord children
        /// </summary>
        internal static DictionaryConfigurationModel CreateInterestingConfigurationModel(LcmCache cache, PropertyTable propertyTable        = null,
                                                                                         DictionaryConfigurationModel.ConfigType configType = DictionaryConfigurationModel.ConfigType.Root)
        {
            var mainHeadwordNode = new ConfigurableDictionaryNode
            {
                FieldDescription      = "HeadWord",
                CSSClassNameOverride  = "entry",
                DictionaryNodeOptions = GetWsOptionsForLanguages(new[] { "fr" }),
                Before = "MainEntry: ",
            };
            var subEntryNode = new ConfigurableDictionaryNode
            {
                Children = new List <ConfigurableDictionaryNode> {
                    mainHeadwordNode
                },
                FieldDescription = "Subentries"
            };
            var mainEntryNode = new ConfigurableDictionaryNode
            {
                Children = new List <ConfigurableDictionaryNode> {
                    mainHeadwordNode
                },
                FieldDescription = "LexEntry"
            };

            if (configType == DictionaryConfigurationModel.ConfigType.Hybrid || configType == DictionaryConfigurationModel.ConfigType.Root)
            {
                mainEntryNode.Children.Add(subEntryNode);
            }
            if (configType == DictionaryConfigurationModel.ConfigType.Hybrid || configType == DictionaryConfigurationModel.ConfigType.Lexeme)
            {
                mainEntryNode.DictionaryNodeOptions = GetFullyEnabledListOptions(cache, DictionaryNodeListOptions.ListIds.Complex);
            }

            CssGeneratorTests.PopulateFieldsForTesting(mainEntryNode);

            var minorEntryNode = mainEntryNode.DeepCloneUnderSameParent();

            minorEntryNode.CSSClassNameOverride = "minorentry";
            minorEntryNode.Before = "MinorEntry: ";
            minorEntryNode.DictionaryNodeOptions = GetFullyEnabledListOptions(cache, DictionaryNodeListOptions.ListIds.Complex);

            var minorSecondNode = minorEntryNode.DeepCloneUnderSameParent();

            minorSecondNode.Before = "HalfStep: ";
            minorSecondNode.DictionaryNodeOptions = GetFullyEnabledListOptions(cache, DictionaryNodeListOptions.ListIds.Variant);

            var model = new DictionaryConfigurationModel
            {
                AllPublications = true,
                Parts           = new List <ConfigurableDictionaryNode> {
                    mainEntryNode, minorEntryNode, minorSecondNode
                },
                FilePath = propertyTable == null ? null : Path.Combine(DictionaryConfigurationListener.GetProjectConfigurationDirectory(propertyTable),
                                                                       "filename" + DictionaryConfigurationModel.FileExtension),
                IsRootBased = configType == DictionaryConfigurationModel.ConfigType.Root
            };

            if (configType != DictionaryConfigurationModel.ConfigType.Root)
            {
                model.Parts.Remove(minorEntryNode);
            }

            return(model);
        }