public void Teardown() { CheckDisposed(); m_cache.Dispose(); m_cache = null; m_ws = null; }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_inMemoryCache != null) { if (m_inMemoryCache != null) { m_inMemoryCache.Dispose(); } } } // Dispose unmanaged resources here, whether disposing is true or false. m_inMemoryCache = null; base.Dispose(disposing); }
public void IFwTool_CloseDbAndWindows() { CheckDisposed(); // Preparations string serverName = MiscUtils.LocalServerName; DummyFwApp app = m_app as DummyFwApp; app.SetFdoCache(serverName, "TestLangProj", Cache); using (InMemoryFdoCache mockedCache = InMemoryFdoCache.CreateInMemoryFdoCache()) { app.SetFdoCache(serverName, "LelaTeli-2", mockedCache.Cache); int pidNew; m_app.NewMainWnd(serverName, "TestLangProj", 1, 0, 0, 0, 0, out pidNew); m_app.NewMainWnd(serverName, "TestLangProj", 1, 0, 0, 0, 0, out pidNew); m_app.NewMainWnd(serverName, "LelaTeli-2", 1, 0, 0, 0, 0, out pidNew); Assert.AreEqual(3, app.m_nMainWnd); app.m_mainWnd[0].Cache = Cache; app.m_mainWnd[1].Cache = Cache; app.m_mainWnd[2].Cache = mockedCache.Cache; // Here is what we want to test ((IFwTool)m_app).CloseDbAndWindows(serverName, "TestLangProj", true); Assert.IsTrue(app.m_mainWnd[0].m_fClosed); Assert.IsTrue(app.m_mainWnd[1].m_fClosed); Assert.IsFalse(app.m_mainWnd[2].m_fClosed); } }
public void Teardown() { CheckDisposed(); m_mock.Dispose(); m_mock = null; m_lp = null; }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_mock != null) { m_mock.Dispose(); } string langFilesPath = Path.Combine(DirectoryFinder.FWDataDirectory, "Languages"); // Delete any language files created by these tests. foreach (string filename in Directory.GetFiles(langFilesPath, "*.xml")) { File.Delete(filename); } // Restore any backed up XML files in the Languages folder to their original names foreach (string filename in Directory.GetFiles(langFilesPath, "*.xml.BAK")) { File.Move(filename, filename.Replace(".xml.BAK", ".xml")); } } // Dispose unmanaged resources here, whether disposing is true or false. m_mock = null; m_lp = null; base.Dispose(disposing); }
public void MultiMessageSynchronize_DifferentCache() { CheckDisposed(); m_mainWnd.ExpectAndReturn("PreSynchronize", true, new IsAnything()); m_mainWnd.ExpectAndReturn("Synchronize", true, new IsAnything()); m_app.MainWindows.Add((IFwMainWnd)m_mainWnd.MockInstance); InMemoryFdoCache differentCache = InMemoryFdoCache.CreateInMemoryFdoCache(); try { DynamicMock otherMainWnd = new DynamicMock(typeof(IFwMainWnd)); otherMainWnd.SetupResult("Cache", differentCache.Cache); otherMainWnd.ExpectAndReturn("PreSynchronize", true, new IsAnything()); otherMainWnd.ExpectAndReturn("Synchronize", true, new IsAnything()); m_app.MainWindows.Add((IFwMainWnd)otherMainWnd.MockInstance); m_app.SuppressSynchronize(Cache); m_app.Synchronize(new SyncInfo(SyncMsg.ksyncUndoRedo, 0, 0), Cache); m_app.Synchronize(new SyncInfo(SyncMsg.ksyncUndoRedo, 0, 0), differentCache.Cache); // This should call (Pre)Synchronize once for each main window m_app.ResumeSynchronize(Cache); m_mainWnd.Verify(); otherMainWnd.Verify(); } finally { differentCache.Dispose(); } }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_app != null) { m_app.Dispose(); // Ensure cache disposed and WSF shutdown. } if (m_inMemoryCache != null) { m_inMemoryCache.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_app = null; m_mainWnd = null; m_inMemoryCache = null; m_isDisposed = true; }
public override void Exit() { CheckDisposed(); m_inMemoryCache.Dispose(); m_inMemoryCache = null; base.Exit(); }
public void SetUp() { CheckDisposed(); m_inMemoryCache = InMemoryFdoCache.CreateInMemoryFdoCache(); m_mainWnd = new DynamicMock(typeof(IFwMainWnd)); m_mainWnd.SetupResult("Cache", Cache); m_app = new DummyFwApp(); }
public void SetUp() { CheckDisposed(); if (m_mock != null) { m_mock.Dispose(); } m_mock = InMemoryFdoCache.CreateInMemoryFdoCache(); m_mock.InitializeWritingSystemEncodings(); m_mock.InitializeLangProject(); m_lp = m_mock.Cache.LangProject; }
public void SetUp() { CheckDisposed(); if (m_cache != null) { m_cache.Dispose(); } m_cache = InMemoryFdoCache.CreateInMemoryFdoCache(); m_cache.InitializeWritingSystemEncodings(); ILgWritingSystemFactory lgwsf = m_cache.Cache.LanguageWritingSystemFactoryAccessor; m_ws = lgwsf.get_EngineOrNull(InMemoryFdoCache.s_wsHvos.En); }
public void Init() { StringUtils.InitIcuDataDir(); m_inMemoryCache = InMemoryFdoCache.CreateInMemoryFdoCache(); m_inMemoryCache.InitializeLangProject(); m_inMemoryCache.Cache.LanguageWritingSystemFactoryAccessor.BypassInstall = true; m_inMemoryCache.InitializeWritingSystemEncodings(); m_dlgWsProps = new DummyWritingSystemPropertiesDialog(m_inMemoryCache.Cache); // "show" the dialog box (the actually gui will never be loaded) // When in test mode the dialog will not call its base ShowDialog m_dlgWsProps.CallShowDialog(); }
public override void Initialize() { CheckDisposed(); Debug.Assert(m_inMemoryCache == null, "m_inMemoryCache is not null, but should be."); //if (m_inMemoryCache != null) // m_inMemoryCache.Dispose(); m_inMemoryCache = CreateInMemoryFdoCache(this); m_inMemoryCache.InitializeLangProject(); m_inMemoryCache.InitializeActionHandler(); InitializeCache(); base.Initialize(); CreateTestData(); }
public void TearDown() { CheckDisposed(); // Note: m_inMemoryCache has to be dispsoed first, // and then the app can be disposed. // Otherwise, m_inMemoryCache can't do waht it wants with // its NewFdoCache object, as it will already have been disposed. if (m_inMemoryCache != null) { m_inMemoryCache.Dispose(); m_inMemoryCache = null; } if (m_app != null) { m_app.Dispose(); // Ensure cache disposed and WSF shutdown. m_app = null; } m_mainWnd = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the in memory fdo cache. /// </summary> /// <param name="provider">The provider.</param> /// ------------------------------------------------------------------------------------ protected virtual InMemoryFdoCache CreateInMemoryFdoCache(IWsFactoryProvider provider) { return(InMemoryFdoCache.CreateInMemoryFdoCache(this)); }
public void Init() { m_inMemoryCache = InMemoryFdoCache.CreateInMemoryFdoCache(); m_inMemoryCache.InitializeLangProject(); }