コード例 #1
0
 public static DictionaryNodeOptions GetWsOptionsForLanguages(string[] languages)
 {
     return(new DictionaryNodeWritingSystemOptions {
         Options = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(languages)
     });
 }
コード例 #2
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");
            }
        }