public void FixtureInit() { Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("db", "ZPU"); m_fdoCache = FdoCache.Create(cacheOptions); }
public override void FixtureSetup() { string partDirectory = Path.Combine(SIL.FieldWorks.Common.Utils.DirectoryFinder.FwSourceDirectory, @"common\controls\detailcontrols\detailcontrolstests"); 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" }; string configurationDir = Path.Combine(SIL.FieldWorks.Common.Utils.DirectoryFinder.FWCodeDirectory, @"Language Explorer\Configuration"); m_stringTable = new SIL.Utils.StringTable(configurationDir); m_layouts = new Inventory(new string[] { partDirectory }, "*Layouts.xml", "/LayoutInventory/*", keyAttrs); keyAttrs = new Dictionary <string, string[]>(); keyAttrs["part"] = new string[] { "id" }; m_parts = new Inventory(new string[] { partDirectory }, "*Parts.xml", "/PartInventory/bin/*", keyAttrs); m_cache = FdoCache.Create("TestLangProj"); m_entry = new LexEntry(); m_cache.LangProject.LexDbOA.EntriesOC.Add(m_entry); m_entry.CitationForm.VernacularDefaultWritingSystem = "rubbish"; // We set both alternatives because currently the default part for Bibliography uses vernacular, // but I think this will probably get fixed. Anyway, this way the test is robust. m_entry.Bibliography.SetAnalysisDefaultWritingSystem("My rubbishy bibliography"); m_entry.Bibliography.SetVernacularDefaultWritingSystem("My rubbishy bibliography"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Configure a PublicationControl /// </summary> /// ------------------------------------------------------------------------------------ public void ConfigurePublication() { Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("db", "TestLangProj"); m_fdoCache = FdoCache.Create(cacheOptions); // Make sure we don't call InstallLanguage during tests. m_fdoCache.LanguageWritingSystemFactoryAccessor.BypassInstall = true; if (m_pub != null) { m_pub.Dispose(); } m_division = new DummyDivision(new DummyHFPrintConfigurer(m_fdoCache), 1); Publication pub = new Publication(m_fdoCache, m_fdoCache.LangProject.TranslatedScriptureOA.PublicationsOC.HvoArray[0]); m_pub = new DummyPublication(pub, m_division, DateTime.Now); m_pub.Configure(); // Check initial state Assert.AreEqual(m_division, m_pub.Divisions[0]); IVwLayoutStream layoutStream = m_division.MainLayoutStream; Assert.IsNotNull(layoutStream); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Set up for a test. /// </summary> /// ------------------------------------------------------------------------------------ public override void FixtureSetup() { base.FixtureSetup(); // set up our cache m_cache = FdoCache.Create("TestLangProj"); m_scr = m_cache.LangProject.TranslatedScriptureOA; }
protected void LoadCache(string name) { Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("db", name); m_fdoCache = FdoCache.Create(cacheOptions); }
public void CreateNewLangProject() { DummyFwNewLangProject dlg = new DummyFwNewLangProject(); string dbName = "Maileingwij2025"; FdoCache cache = null; if (DbExists(dbName)) { DestroyDb(dbName, true); } dlg.ProjectName = dbName; try { dlg.CreateNewLangProj(); Assert.IsTrue(DbExists(dbName)); // // REVIEW: An FDO cache can not be created at this time until the scripture // // object is created. This happens when the database is loaded. // // Check to see if the writing systems were added correctly. // cache = FdoCache.Create(dbName); // Assert.AreEqual(dbName, cache.LangProject.Name.AnalysisDefaultWritingSystem); // Assert.AreEqual(1, cache.LangProject.AnalysisWssRC.Count); // Assert.AreEqual(1, cache.LangProject.VernWssRC.Count); // Assert.AreEqual(1, cache.LangProject.CurAnalysisWssRS.Count); // Assert.AreEqual(1, cache.LangProject.CurVernWssRS.Count); // // foreach (LgWritingSystem ws in cache.LangProject.AnalysisWssRC) // { // Assert.AreEqual("something", ws.Name.GetAlternative(cache.DefaultUserWs)); // } // foreach (LgWritingSystem ws in cache.LangProject.VernWssRC) // { // Assert.AreEqual(dbName, ws.Name.GetAlternative(cache.DefaultUserWs)); // } // foreach (LgWritingSystem ws in cache.LangProject.CurAnalysisWssRS) // { // Assert.AreEqual("something", ws.Name.GetAlternative(cache.DefaultUserWs)); // } // foreach (LgWritingSystem ws in cache.LangProject.CurVernWssRS) // { // Assert.AreEqual(dbName, ws.Name.GetAlternative(cache.DefaultUserWs)); // } cache = FdoCache.Create(dbName); CheckInitialSetOfPartsOfSpeech(cache); } finally { // Blow away the database to clean things up if (cache != null) { cache.Dispose(); } DestroyDb(dbName, false); } }
protected FdoCache LoadCache(string name) { Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("db", name); // where does this cache get disposed? Have to explicitly call cache.Dispose() somewhere! return(FdoCache.Create(cacheOptions)); }
public void Init() { Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("c", MiscUtils.LocalServerName); cacheOptions.Add("db", "TestLangProj"); cacheOptions.Add("proj", "Kalaba"); m_cache = FdoCache.Create(cacheOptions); }
public void Setup() { Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("db", "TestLangProj"); m_fdoCache = FdoCache.Create(cacheOptions); m_pageInfo = new DummyPageInfo(); m_vc = new HeaderFooterVc(m_pageInfo, m_fdoCache.DefaultVernWs, DateTime.Now, m_fdoCache); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="DetailControlsMainWnd"/> class. /// </summary> /// ----------------------------------------------------------------------------------- public DetailControlsMainWnd() { // // Required for Windows Form Designer support // InitializeComponent(); m_cache = FdoCache.Create("TestLangProj"); InitAndShowClient(); }
public override void FixtureSetup() { CheckDisposed(); base.FixtureSetup(); m_fdoCache = FdoCache.Create("TestLangProj"); m_scr = m_fdoCache.LangProject.TranslatedScriptureOA; // For these tests we don't need to run InstallLanguage. m_wsf = m_fdoCache.LanguageWritingSystemFactoryAccessor; m_wsf.BypassInstall = true; }
public override void FixtureSetup() { base.FixtureSetup(); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); m_fdoCache = FdoCache.Create("TestLangProj"); m_scr = (Scripture)m_fdoCache.LangProject.TranslatedScriptureOA; ScrReferenceTests.InitializeScrReferenceForTests(); }
public override void Initialize() { CheckDisposed(); m_cache = FdoCache.Create("TestLangProj"); m_filter = new FilteredScrBooks(m_cache, 123); m_filter.ShowAllBooks(); m_fileName = Path.GetTempFileName(); File.Delete(m_fileName); // exporter pops up dialog if file exists! m_exporter = new ExportXml(m_fileName, m_cache, m_filter, ExportWhat.AllBooks, 0, 0, 0, "This is a test"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initialize a cache for testing. This is static public so other tests that do not /// derive from InDatabaseFdoTestBase can create a cache in the same way. /// </summary> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static FdoCache SetupCache() { FdoCache cache = FdoCache.Create("TestLangProj"); // For these tests we don't need to run InstallLanguage. ILgWritingSystemFactory wsf = cache.LanguageWritingSystemFactoryAccessor; wsf.BypassInstall = true; // Don't suppress adding undo actions. cache.AddAllActionsForTests = true; return(cache); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create the Db connection /// </summary> /// ------------------------------------------------------------------------------------ public override void FixtureSetup() { base.FixtureSetup(); Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("db", "TestLangProj"); m_fdoCache = FdoCache.Create(cacheOptions); // Make sure we don't call InstallLanguage during tests. m_fdoCache.LanguageWritingSystemFactoryAccessor.BypassInstall = true; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Get the server and name to be used for establishing a database connection. First /// try to get this info based on the command-line arguments. If not given, try using /// the info in the registry. Otherwise, just get the first FW database on the local /// server. /// </summary> /// <returns>A new FdoCache, based on options, or null, if not found.</returns> /// <remarks>This method was originally taken from FwApp.cs</remarks> /// ----------------------------------------------------------------------------------- private FdoCache GetCache() { Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("c", MiscUtils.LocalServerName); cacheOptions.Add("db", "TestLangProj"); FdoCache cache = null; cache = FdoCache.Create(cacheOptions); return(cache); // After all of this, it may be still be null, so watch out. }
static void Main(string[] args) { string db = args[0]; FdoCache c = FdoCache.Create(db); Console.WriteLine("Loaded Cache: " + c.ToString()); FixUp f = new FixUp(c); f.AddMissingMSAs(); f.RemoveExtraAnalyses(); c.Dispose(); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Get the server and name to be used for establishing a database connection. First /// try to get this info based on the command-line arguments. If not given, try using /// the info in the registry. Otherwise, just get the first FW database on the local /// server. /// </summary> /// <returns>A new FdoCache, based on options, or null, if not found.</returns> /// <remarks>This method was originally taken from FwApp.cs</remarks> /// ----------------------------------------------------------------------------------- private FdoCache GetCache() { Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("c", MiscUtils.LocalServerName); cacheOptions.Add("db", "TestLangProj"); FdoCache cache = FdoCache.Create(cacheOptions); // For these tests we don't need to run InstallLanguage. ILgWritingSystemFactory wsf = cache.LanguageWritingSystemFactoryAccessor; wsf.BypassInstall = true; return(cache); // After all of this, it may be still be null, so watch out. }
public void TwoWordforms() { int hvoBearTEST = CheckAnalysisSize("bearTEST", 0, true); int hvoBullTEST = CheckAnalysisSize("bullTEST", 0, true); string xmlFragment = ""; using (FdoCache cache = FdoCache.Create("TestLangProj")) { ILexDb ldb = cache.LangProject.LexDbOA; // Bear ILexEntry bearN = (ILexEntry)ldb.EntriesOC.Add(new LexEntry()); AddIdToList(bearN.Hvo); IMoStemAllomorph bearNForm = (IMoStemAllomorph)bearN.AlternateFormsOS.Append(new MoStemAllomorph()); bearNForm.Form.VernacularDefaultWritingSystem = "bearNTEST"; IMoStemMsa bearNMSA = (IMoStemMsa)bearN.MorphoSyntaxAnalysesOC.Add(new MoStemMsa()); // Bull ILexEntry bullN = (ILexEntry)ldb.EntriesOC.Add(new LexEntry()); AddIdToList(bullN.Hvo); IMoStemAllomorph bullNForm = (IMoStemAllomorph)bullN.AlternateFormsOS.Append(new MoStemAllomorph()); bullNForm.Form.VernacularDefaultWritingSystem = "bullNTEST"; IMoStemMsa bullNMSA = (IMoStemMsa)bullN.MorphoSyntaxAnalysesOC.Add(new MoStemMsa()); xmlFragment = "<Wordform DbRef='" + hvoBearTEST.ToString() + "' Form='bearTEST'>\n" + "<WfiAnalysis>\n" + "<Morphs>\n" + "<Morph>\n" + "<MoForm DbRef='" + bearNForm.Hvo.ToString() + "' Label='bearNTEST'/>\n" + "<MSI DbRef='" + bearNMSA.Hvo.ToString() + "'/>\n" + "</Morph>\n" + "</Morphs>\n" + "</WfiAnalysis>\n" + "</Wordform>\n" + "<Wordform DbRef='" + hvoBullTEST.ToString() + "' Form='bullTEST'>\n" + "<WfiAnalysis>\n" + "<Morphs>\n" + "<Morph>\n" + "<MoForm DbRef='" + bullNForm.Hvo.ToString() + "' Label='bullNTEST'/>\n" + "<MSI DbRef='" + bullNMSA.Hvo.ToString() + "'/>\n" + "</Morph>\n" + "</Morphs>\n" + "</WfiAnalysis>\n" + "</Wordform>\n"; } m_filer.ProcessParse(MakeXML(xmlFragment, true)); CheckAnalysisSize("bearTEST", 1, false); CheckAnalysisSize("bullTEST", 1, false); }
public void Init() { m_cache = FdoCache.Create("TestLangProj"); m_Scripture = m_cache.LangProject.TranslatedScriptureOA; // Make sure we don't call InstallLanguage during tests. m_cache.LanguageWritingSystemFactoryAccessor.BypassInstall = true; m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(m_cache, m_Scripture.Hvo, (int)Scripture.ScriptureTags.kflidStyles); m_mapping = new ImportMappingInfo("emph{", "}", "Emphasis"); Options.ShowTheseStylesSetting = Options.ShowTheseStyles.All; m_dialog = new DummyCharacterMappingSettings(m_mapping, m_styleSheet, m_cache); m_dialog.StyleListHelper.MaxStyleLevel = int.MaxValue; }
public void Init() { CheckDisposed(); m_builder = new DummySFFileListBuilder(); m_cache = FdoCache.Create("TestLangProj"); if (!m_cache.DatabaseAccessor.IsTransactionOpen()) { m_cache.DatabaseAccessor.BeginTrans(); } m_cache.BeginUndoTask("Undo SfFileListBuilderTest", "Redo SfFileListBuilderTest"); m_settings = new ScrImportSet(); m_cache.LangProject.TranslatedScriptureOA.DefaultImportSettings = m_settings; }
public void Setup() { string sBackupFile = UnzipBackup(); RestoreDbBackup(sBackupFile, "FlexChorusTest"); // now, create the data cache for the test project. Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("c", MiscUtils.LocalServerName); cacheOptions.Add("db", "FlexChorusTest"); m_cache = FdoCache.Create(cacheOptions); Debug.Assert(m_cache != null); m_cache.EnableBulkLoadingIfPossible(true); InstallVirtuals(@"Language Explorer\Configuration\Main.xml", new string[] { "SIL.FieldWorks.FDO.", "SIL.FieldWorks.IText." }); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="Form1"/> class. /// </summary> /// ----------------------------------------------------------------------------------- public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); AccessibleName = GetType().Name; m_parsers = new List <ParserConnection>(); m_selectedFdoCache = FdoCache.Create("TestLangProj"); // per KenZ, convention is for server to already include the \\SILFW,e.g. HATTON1\\SILFW //m_parsers.Add(new ParserConnection(".\\SILFW", "test", "test")); m_parsers.Add(new ParserConnection(".\\SILFW", "TestLangProj", "TestLangProj", true)); m_selectedParserConnection = m_parsers[0]; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create temp registry settings and unzipped files /// </summary> /// ------------------------------------------------------------------------------------ public override void FixtureSetup() { CheckDisposed(); base.FixtureSetup(); m_fdoCache = FdoCache.Create(ksLangProj); // For these tests we don't need to run InstallLanguage. ILgWritingSystemFactory wsf = m_fdoCache.LanguageWritingSystemFactoryAccessor; wsf.BypassInstall = true; // Use a transaction because fiddling with Field$ lies outside the Undo/Redo // mechanism. m_fdoCache.DatabaseAccessor.BeginTrans(); string sSql = "Server=" + m_fdoCache.ServerName + "; Database=" + m_fdoCache.DatabaseName + "; User ID=FWDeveloper; Password=careful; Pooling=false;"; m_sqlCon = new SqlConnection(sSql); m_sqlCon.Open(); }
public void InitTest() { CheckDisposed(); Debug.Assert(m_cache == null, "m_cache is not null."); //if (m_cache != null) // m_cache.Dispose(); m_cache = FdoCache.Create("TestLangProj"); // Make sure we don't call InstallLanguage during tests. m_cache.LanguageWritingSystemFactoryAccessor.BypassInstall = true; m_styleSheet = new FwStyleSheet(); // Force load of styles IScripture scr = m_cache.LangProject.TranslatedScriptureOA; Assert.IsTrue(scr.StylesOC.Count > 0); m_styleSheet.Init(m_cache, scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); }
/// <summary> /// /// </summary> internal TimeStamp RetrieveModel(SqlConnection connection, string LangProject, TaskReport parentTask, ParserScheduler.NeedsUpdate eNeedsUpdate) { TimeStamp began = new TimeStamp(connection); using (FdoCache cache = FdoCache.Create(connection.DataSource, connection.Database, null)) { BaseVirtualHandler.InstallVirtuals(@"Language Explorer\Configuration\Main.xml", new string[] { "SIL.FieldWorks.FDO.", "SIL.FieldWorks.IText." }, cache, true); string sDescription; string sFxtFile; SetDescriptionAndFxtFile(eNeedsUpdate, out sDescription, out sFxtFile); using (m_topLevelTask = parentTask.AddSubTask(sDescription)) { m_taskStack.Push(m_topLevelTask); string sFxtPath = Path.Combine(DirectoryFinder.FWCodeDirectory, sFxtFile); m_sFxtOutputPath = Path.Combine(m_outputDirectory, m_database + "ParserFxtResult.xml"); if ((eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData) && File.Exists(m_sFxtTemplateOutputPath)) { try { DoUpdate(cache, sFxtPath, ref m_modelDom); DoUpdate(cache, m_sGafawsFxtPath, ref m_templateDom); } // (SteveMiller): Unremarked, the following often causes an error: // Warning as Error: The variable 'e' is declared but never used catch (XUpdaterException) { //Trace.WriteLine("XUpdater exception caught: " + e.Message); // do something useful for the user DoDump(eNeedsUpdate, cache, sFxtPath); } } else { DoDump(eNeedsUpdate, cache, sFxtPath); } } } m_topLevelTask = null; return(began); }
public void FDOCompetingTransactions() { CheckDisposed(); FdoCache a = FdoCache.Create("TestlangProj"); AddWord(a); UndoResult ures_a = 0; while (a.CanUndo) { a.Undo(out ures_a); if (ures_a == UndoResult.kuresFailed || ures_a == UndoResult.kuresError) { Assert.Fail("ures should not be == " + ures_a.ToString()); } } a.Dispose(); FdoCache b = FdoCache.Create("TestlangProj"); AddWord(b); UndoResult ures_b = 0; while (b.CanUndo) { b.Undo(out ures_b); if (ures_b == UndoResult.kuresFailed || ures_b == UndoResult.kuresError) { Assert.Fail("ures should not be == " + ures_b.ToString()); } } b.Dispose(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is a constructor, dude! /// </summary> /// <remarks>Cache created here gets disposed in the teardown method</remarks> /// ------------------------------------------------------------------------------------ public DummyTeMainWnd() : base(FdoCache.Create("TestLangProj"), null) { // Make sure we don't call InstallLanguage during tests. m_cache.LanguageWritingSystemFactoryAccessor.BypassInstall = true; }
public void Setup() { m_cache = FdoCache.Create("TestLangProj"); m_sda = m_cache.MainCacheAccessor; }
static void Main(string[] arguments) { /// <summary> /// any filters that we want, for example, to only output items which satisfy their constraint. /// </summary> IFilterStrategy[] filters = null; if (arguments.Length < 3) { Console.WriteLine("usage: fxt dbName fxtTemplatePath xmlOutputPath (-guids)"); Console.WriteLine(""); Console.WriteLine("example using current directory: fxt TestLangProj WebPageSample.xhtml LangProj.xhtml"); Console.WriteLine("example with environment variables: fxt ZPU \"%fwroot%/distfiles/fxtTest.fxt\" \"%temp%/fxtTest.xml\""); return; } string fxtPath = System.Environment.ExpandEnvironmentVariables(arguments[1]); if (!File.Exists(fxtPath)) { Console.WriteLine("could not find the file " + fxtPath); return; } string outputPath = System.Environment.ExpandEnvironmentVariables(arguments[2]); FdoCache cache = null; try { Console.WriteLine("Initializing cache..."); Dictionary <string, string> cacheOptions = new Dictionary <string, string>(); cacheOptions.Add("db", arguments[0]); cache = FdoCache.Create(cacheOptions); } catch (Exception error) { Console.WriteLine(error.Message); return; } Console.WriteLine("Beginning output..."); DateTime dtstart = DateTime.Now; XDumper d = new XDumper(cache); if (arguments.Length == 4) { if (arguments[3] == "-parserDump") { filters = new IFilterStrategy[] { new ConstraintFilterStrategy() }; } else { //boy do we have a brain-dead argument parser in this app! System.Diagnostics.Debug.Assert(arguments[3] == "-guids"); } d.OutputGuids = true; } try { d.Go(cache.LangProject as CmObject, fxtPath, File.CreateText(outputPath), filters); //clean up, add the <?xml tag, etc. Won't be necessary if/when we make the dumper use an xmlwriter instead of a textwriter //was introducing changes such as single quote to double quote XmlDocument doc=new XmlDocument(); // doc.Load(outputPath); // doc.Save(outputPath); } catch (Exception error) { if (cache != null) { cache.Dispose(); } Console.WriteLine(error.Message); return; } TimeSpan tsTimeSpan = new TimeSpan(DateTime.Now.Ticks - dtstart.Ticks); Console.WriteLine("Finished: " + tsTimeSpan.TotalSeconds.ToString() + " Seconds"); if (outputPath.ToLower().IndexOf("fxttestout") > -1) { System.Diagnostics.Debug.WriteLine(File.OpenText(outputPath).ReadToEnd()); } if (cache != null) { cache.Dispose(); } System.Diagnostics.Debug.WriteLine("Finished: " + tsTimeSpan.TotalSeconds.ToString() + " Seconds"); }