예제 #1
0
        public virtual void FixtureSetup()
        {
            SetupTestModel(Properties.Resources.TextCacheModel_xml);

            m_cache = new T();
            m_cache.MetaDataCache      = MetaDataCache.CreateMetaDataCache("TestModel.xml");
            m_cache.ParaContentsFlid   = SimpleRootsiteTestsConstants.kflidParaContents;
            m_cache.ParaPropertiesFlid = SimpleRootsiteTestsConstants.kflidParaProperties;
            m_cache.TextParagraphsFlid = SimpleRootsiteTestsConstants.kflidTextParas;

            Debug.Assert(m_wsManager == null);
            m_wsManager = new WritingSystemManager();
            m_cache.WritingSystemFactory = m_wsManager;

            CoreWritingSystemDefinition enWs;

            m_wsManager.GetOrSet("en", out enWs);
            m_wsEng = enWs.Handle;

            CoreWritingSystemDefinition frWs;

            m_wsManager.GetOrSet("fr", out frWs);
            m_wsFrn = frWs.Handle;

            CoreWritingSystemDefinition deWs;

            m_wsManager.GetOrSet("de", out deWs);
            m_wsDeu = deWs.Handle;

            m_wsManager.UserWs = m_wsEng;
            m_wsUser           = m_wsManager.UserWs;
        }
예제 #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FwModelBrowser"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public FwModelBrowser()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

#if USINGCPP
            m_ode = OleDbEncapClass.Create();
            m_ode.Init(SystemInformation.ComputerName + "\\SILFW", "TestLangProj", null,
                       FwKernelLib.OdeLockTimeoutMode.koltReturnError,
                       (int)FwKernelLib.OdeLockTimeoutValue.koltvFwDefault);
            m_mdc = FwMetaDataCacheClass.Create();
            m_mdc.Init(m_ode);
#else
            string modelDir = DirectoryFinder.FwSourceDirectory;
            modelDir = modelDir.Substring(0, modelDir.LastIndexOf('\\'));
            modelDir = Path.Combine(modelDir, @"Output\XMI");
            m_mdc    = MetaDataCache.CreateMetaDataCache(Path.Combine(modelDir, "xmi2cellar3.xml"));
#endif

            uint   clid      = 0;
            string classname = m_mdc.GetClassName(clid);
            m_tvClasses.SuspendLayout();
            AddNode(m_tvClasses.Nodes, classname, clid);
            m_tvClasses.Nodes[0].Expand();
            m_tvClasses.ResumeLayout(false);
        }
예제 #3
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            SetupTestModel(Properties.Resources.TextCacheModel_xml);

            m_cache = new RealDataCache();
            m_cache.MetaDataCache      = MetaDataCache.CreateMetaDataCache("TestModel.xml");
            m_cache.ParaContentsFlid   = kflidParaContents;
            m_cache.ParaPropertiesFlid = kflidParaProperties;
            m_cache.TextParagraphsFlid = kflidTextParas;

            Debug.Assert(m_wsManager == null);
            m_wsManager = new PalasoWritingSystemManager();
            m_cache.WritingSystemFactory = m_wsManager;

            IWritingSystem enWs;

            m_wsManager.GetOrSet("en", out enWs);
            m_wsEng = enWs.Handle;

            IWritingSystem frWs;

            m_wsManager.GetOrSet("fr", out frWs);
            m_wsFrn = frWs.Handle;

            IWritingSystem deWs;

            m_wsManager.GetOrSet("de", out deWs);
            m_wsDeu = deWs.Handle;

            m_wsManager.UserWs = m_wsEng;
            m_wsUser           = m_wsManager.UserWs;
        }
예제 #4
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            SetupTestModel(Resources.TextCacheModel_xml);

            m_sda = new RealDataCache();
            m_sda.MetaDataCache = MetaDataCache.CreateMetaDataCache("TestModel.xml");
            //m_cache.ParaContentsFlid = kflidParaContents;
            //m_cache.ParaPropertiesFlid = kflidParaProperties;
            //m_cache.TextParagraphsFlid = kflidTextParas;

            Debug.Assert(m_wsManager == null);
            m_wsManager = Cache.ServiceLocator.GetInstance <IWritingSystemManager>();
            m_sda.WritingSystemFactory = m_wsManager;

            m_wsAnal = Cache.DefaultAnalWs;

            m_wsVern = Cache.DefaultVernWs;

            //IWritingSystem deWs;
            //m_wsManager.GetOrSet("de", out deWs);
            //m_wsDeu = deWs.Handle;

            //m_wsManager.UserWs = m_wsEng;
            //m_wsUser = m_wsManager.UserWs;

            m_tsf = TsStrFactoryClass.Create();

            m_hvoLexDb = m_sda.MakeNewObject(kclsidLexDb, 0, -1, -1);

            kflidLexDb_Entries = m_sda.MetaDataCache.GetFieldId("LexDb", "Entries", false);
            kflidEntry_Form    = m_sda.MetaDataCache.GetFieldId("Entry", "Form", false);
            kflidEntry_Summary = m_sda.MetaDataCache.GetFieldId("Entry", "Summary", false);

            m_hvoKick = m_sda.MakeNewObject(kclsidEntry, m_hvoLexDb, kflidLexDb_Entries, 0);
            m_sda.SetMultiStringAlt(m_hvoKick, kflidEntry_Form, m_wsVern, m_tsf.MakeString("kick", m_wsVern));
            m_sda.SetString(m_hvoKick, kflidEntry_Summary, m_tsf.MakeString("strike with foot", m_wsAnal));

            var keyAttrs = new Dictionary <string, string[]>();

            keyAttrs["layout"] = new[] { "class", "type", "name", "choiceGuid" };
            keyAttrs["group"]  = new[] { "label" };
            keyAttrs["part"]   = new[] { "ref" };
            var layoutInventory = new Inventory("*.fwlayout", "/LayoutInventory/*", keyAttrs, "test", "nowhere");

            layoutInventory.LoadElements(Resources.Layouts_xml, 1);

            keyAttrs         = new Dictionary <string, string[]>();
            keyAttrs["part"] = new[] { "id" };

            var partInventory = new Inventory("*Parts.xml", "/PartInventory/bin/*", keyAttrs, "test", "nowhere");

            partInventory.LoadElements(Resources.Parts_xml, 1);

            m_layouts = new LayoutCache(m_sda.MetaDataCache, layoutInventory, partInventory);
        }
예제 #5
0
 public virtual void FixtureSetup()
 {
     FileUtils.Manager.SetFileAdapter(new MockFileOS());
     using (TextWriter fw = FileUtils.OpenFileForWrite("TestModel.xsd", Encoding.UTF8))
         fw.Write(Properties.Resources.TestModel_xsd);
     using (TextWriter fw = FileUtils.OpenFileForWrite("TestModel.xml", Encoding.UTF8))
         fw.Write(Properties.Resources.TestModel_xml);
     m_metaDataCache = MetaDataCache.CreateMetaDataCache("TestModel.xml");
 }
예제 #6
0
        public virtual void FixtureSetup()
        {
            CheckDisposed();

            string modelDir = DirectoryFinder.FwSourceDirectory;

            modelDir        = modelDir.Substring(0, modelDir.LastIndexOf('\\'));
            modelDir        = Path.Combine(modelDir, @"Output\XMI");
            m_realDataCache = new RealDataCache();
            m_realDataCache.MetaDataCache = MetaDataCache.CreateMetaDataCache(Path.Combine(modelDir, "xmi2cellar3.xml"));
        }
예제 #7
0
        public void CreateMetaDataCacheDuplicateClassesInTwoFiles()
        {
            var bogusDataPathname = "Good.xml";

            using (var w = FileUtils.OpenFileForWrite(bogusDataPathname, Encoding.UTF8))
            {
                w.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
                w.WriteLine("<EntireModel>");
                w.WriteLine("<class num='0' id='BaseClass' abstract='true'/>");
                w.WriteLine("<class num='1' id='ClassA' abstract='false' base='BaseClass'/>");
                w.WriteLine("</EntireModel>");
                w.Flush();
                w.Close();
            }
            IFwMetaDataCache mdc;

            try
            {
                mdc = MetaDataCache.CreateMetaDataCache(bogusDataPathname);
            }
            finally
            {
                FileUtils.Delete(bogusDataPathname);
            }
            // Not good, since a file with that name has already been processed.
            bogusDataPathname = "ReallyGood.xml";
            using (var w = FileUtils.OpenFileForWrite(bogusDataPathname, Encoding.UTF8))
            {
                w.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
                w.WriteLine("<EntireModel>");
                w.WriteLine("<class num='1' id='ClassA' abstract='false' base='BaseClass'/>");
                w.WriteLine("</EntireModel>");
                w.Flush();
                w.Close();
            }
            try
            {
                mdc.InitXml(bogusDataPathname, false);
            }
            finally
            {
                FileUtils.Delete(bogusDataPathname);
            }
        }
예제 #8
0
        public void CreateMetaDataCacheNotXMLData()
        {
            // <?xml version="1.0" encoding="utf-8"?>
            const string bogusDataPathname = "Bogus.txt";

            using (var w = FileUtils.OpenFileForWrite(bogusDataPathname, Encoding.UTF8))
            {
                w.WriteLine("Non-XML data");
                w.Flush();
                w.Close();
            }
            try
            {
                MetaDataCache.CreateMetaDataCache(bogusDataPathname);
            }
            finally
            {
                FileUtils.Delete(bogusDataPathname);
            }
        }
예제 #9
0
        public void CreateMetaDataCacheCellarModuleXMLData()
        {
            const string bogusDataPathname = "Bogus.xml";

            using (var w = FileUtils.OpenFileForWrite(bogusDataPathname, Encoding.UTF8))
            {
                w.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
                w.WriteLine("<EntireModel/>");
                w.Flush();
                w.Close();
            }
            try
            {
                MetaDataCache.CreateMetaDataCache(bogusDataPathname);
            }
            finally
            {
                FileUtils.Delete(bogusDataPathname);
            }
        }
예제 #10
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            SimpleRootsiteTestsBase <RealDataCache> .SetupTestModel(Properties.Resources.RootSiteDataProviderCacheModel_xml);

            m_cache = new RealDataCache {
                MetaDataCache = MetaDataCache.CreateMetaDataCache("TestModel.xml")
            };

            if (m_wsManager != null)
            {
                throw new ApplicationException("m_wsManager was not null");
            }
            m_wsManager = new PalasoWritingSystemManager();
            m_cache.WritingSystemFactory = m_wsManager;
            m_wsEng = m_wsManager.Set("en").Handle;
            m_wsFr  = m_wsManager.Set("fr").Handle;

            FixtureStyleSheet = new SimpleStyleSheet(m_cache);
        }
예제 #11
0
        public void CreateMetaDataCacheDuplicateFiles()
        {
            const string bogusDataPathname = "Good.xml";

            using (var w = FileUtils.OpenFileForWrite(bogusDataPathname, Encoding.UTF8))
            {
                w.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
                w.WriteLine("<EntireModel/>");
                w.Flush();
                w.Close();
            }
            IFwMetaDataCache mdc;

            try
            {
                mdc = MetaDataCache.CreateMetaDataCache(bogusDataPathname);
            }
            finally
            {
                FileUtils.Delete(bogusDataPathname);
            }
            // Not good, since a file with that name has already been processed.
            using (var w = File.CreateText(bogusDataPathname))
            {
                w.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
                w.WriteLine("<EntireModel/>");
                w.Flush();
                w.Close();
            }
            try
            {
                mdc.InitXml(bogusDataPathname, false);
            }
            finally
            {
                FileUtils.Delete(bogusDataPathname);
            }
        }
예제 #12
0
        public void CreateMetaDataCacheNonDuplicateClasses()
        {
            const string bogusDataPathname = "Good.xml";

            using (var w = FileUtils.OpenFileForWrite(bogusDataPathname, Encoding.UTF8))
            {
                w.WriteLine("<?xml version='1.0' encoding='utf-8'?>");
                w.WriteLine("<EntireModel>");
                w.WriteLine("<class num='0' id='BaseClass' abstract='true'/>");
                w.WriteLine("<class num='2' id='ClassD' abstract='false' base='BaseClass'/>");
                w.WriteLine("<class num='14' id='LexPronunciation' abstract='false' base='BaseClass'/>");
                w.WriteLine("</EntireModel>");
                w.Flush();
                w.Close();
            }
            try
            {
                MetaDataCache.CreateMetaDataCache(bogusDataPathname);
            }
            finally
            {
                FileUtils.Delete(bogusDataPathname);
            }
        }
예제 #13
0
 public void CreateMetaDataCacheBadPathname()
 {
     MetaDataCache.CreateMetaDataCache("MyBadpathname");
 }
예제 #14
0
 public void CreateMetaDataCacheEmptyPathname()
 {
     MetaDataCache.CreateMetaDataCache("");
 }
예제 #15
0
 public void CreateMetaDataCacheNoFile()
 {
     MetaDataCache.CreateMetaDataCache(null);
 }
예제 #16
0
        public void Setup()
        {
            // Create the following:
            // - part and layout inventories
            // - metadata cache
            // - DataAccess cache
            // - collection of columns to display.

            // We want a MetaDataCache that knows about
            // - LexEntry.Senses, Msas, CitationForm, Bibliography, Etymology
            // - LexSense.SemanticDomains, SenseType, Status, gloss
            // - CmPossibility Name, abbr
            // - MoMorphSynAnalysis
            // - MoStemMsa
            // - MoDerivationalMsa
            string m_sTestPath = Path.Combine(DirectoryFinder.FwSourceDirectory,
                                              Path.Combine("Common",
                                                           Path.Combine("Controls",
                                                                        Path.Combine("XMLViews",
                                                                                     Path.Combine("XMLViewsTests", "SampleCm.xml")))));

            m_mdc = MetaDataCache.CreateMetaDataCache(m_sTestPath);

            // We want ISilDataAccess with:
            // - LexEntry (1) with no senses and one MSA (2)
            // - LexEntry (4) with one sense (5) and no MSA
            // - LexEntry (6) with three senses (7, 8, 9) and two MSAs (10, 11)
            // - sense(5) with no semantic domains
            // - senses with one SD (7->30, 8->31)
            // - sense with three SDs, one the same as the first (9->30, 31, 32)
            // - MoStemMsa (2, 11)
            // - MoDerivationalMsa (10)
            m_cda       = VwCacheDaClass.Create();
            m_sda       = m_cda as ISilDataAccess;
            m_wsManager = new PalasoWritingSystemManager();
            m_sda.WritingSystemFactory = m_wsManager;
            var parser = new SimpleDataParser(m_mdc, m_cda);

            parser.Parse(Path.Combine(DirectoryFinder.FwSourceDirectory,
                                      Path.Combine("Common",
                                                   Path.Combine("Controls",
                                                                Path.Combine("XMLViews",
                                                                             Path.Combine("XMLViewsTests", "SampleData.xml"))))));
            int wsEn = m_wsManager.GetWsFromStr("en");

            // These are mainly to check out the parser.
            Assert.AreEqual(3, m_sda.get_ObjectProp(2, 23011), "part of speech of an MoStemMsa");
            Assert.AreEqual(2, m_sda.get_VecItem(1, 2009, 0), "owned msa");
            Assert.AreEqual("noun", m_sda.get_MultiStringAlt(3, 7003, wsEn).Text, "got ms property");
            Assert.AreEqual(9, m_sda.get_VecItem(6, 2010, 2), "3rd sense");
            Assert.AreEqual(31, m_sda.get_VecItem(9, 21016, 1), "2nd semantic domain");

            // Columns includes
            // - CitationForm (string inside span)
            // - Bibliography (string not in span)
            // - Sense glosses (string in para in seq, nested in column element)
            // - Semantic domains (pair of strings in para in seq in seq, using layout refs)
            // - MSAs (simplified, but polymorphic with one having <choice> and one <obj> to CmPossibility
            XmlDocument docColumns = new XmlDocument();

            docColumns.Load(Path.Combine(DirectoryFinder.FwSourceDirectory,
                                         Path.Combine("Common",
                                                      Path.Combine("Controls",
                                                                   Path.Combine("XMLViews",
                                                                                Path.Combine("XMLViewsTests", "TestColumns.xml"))))));
            m_columnList = docColumns.DocumentElement.ChildNodes;

            // Parts just has what those columns need.
            string partDirectory = Path.Combine(DirectoryFinder.FwSourceDirectory,
                                                Path.Combine("Common",
                                                             Path.Combine("Controls",
                                                                          Path.Combine("XMLViews", "XMLViewsTests"))));
            Dictionary <string, string[]> keyAttrs = new Dictionary <string, string[]>();

            keyAttrs["layout"] = new string[] { "class", "type", "name" };
            keyAttrs["group"]  = new string[] { "label" };
            keyAttrs["part"]   = new string[] { "ref" };


            // Currently there are no specialized layout files that match.
            m_layoutInventory = new Inventory(new string[] { partDirectory },
                                              "*.fwlayout", "/LayoutInventory/*", keyAttrs, "TestManyOneBrowse", "ProjectPath");

            keyAttrs         = new Dictionary <string, string[]>();
            keyAttrs["part"] = new string[] { "id" };

            m_partInventory = new Inventory(new string[] { partDirectory },
                                            "TestParts.xml", "/PartInventory/bin/*", keyAttrs, "TestManyOneBrowse", "ProjectPath");
            m_layouts = new LayoutCache(m_mdc, m_layoutInventory, m_partInventory);
        }