public void Remove_CollectionWithSingleElement_CollectionShouldBeEmpty() { using (var listBox = new FwListBox()) { using (var collection = new FwListBox.ObjectCollection(listBox)) { ITsString testString = TsStringHelper.MakeTSS("test", m_hvoEnglishWs); collection.Add(testString); // The Test collection.Remove(testString); Assert.AreEqual(0, collection.Count); Assert.IsFalse(collection.Contains(testString)); } } }
public void Add_EmptyObjectCollection_CollectionContainsSingleElement() { using (var listBox = new FwListBox()) { using (var collection = new FwListBox.ObjectCollection(listBox)) { ITsString testString = TsStringHelper.MakeTSS("test", m_hvoEnglishWs); // The Test collection.Add(testString); Assert.AreEqual(1, collection.Count); Assert.IsTrue(collection.Contains(testString)); } } }
/// <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. Clear(); } // Dispose unmanaged resources here, whether disposing is true or false. m_list = null; m_owner = null; m_isDisposed = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct with supplied initial items. /// </summary> /// <param name="owner"></param> /// <param name="values"></param> /// ------------------------------------------------------------------------------------ public ObjectCollection(FwListBox owner, ObjectCollection values) { m_list = new ArrayList(values); m_owner = owner; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct empty. /// </summary> /// <param name="owner"></param> /// ------------------------------------------------------------------------------------ public ObjectCollection(FwListBox owner) { m_list = new ArrayList(); m_owner = owner; }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; base.Dispose(disposing); if (disposing) { // Cleanup managed stuff here. if (m_vc != null) m_vc.Dispose(); } // Cleanup unmanaged stuff here. m_DataAccess = null; if (m_CacheDa != null) { m_CacheDa.ClearAllData(); if (Marshal.IsComObject(m_CacheDa)) Marshal.ReleaseComObject(m_CacheDa); m_CacheDa = null; } m_owner = null; // It will get disposed on its own, if it hasn't been already. m_vc = null; }
/// <summary> /// Constructor /// </summary> internal InnerFwListBox(FwListBox owner) { m_owner = owner; m_CacheDa = VwCacheDaClass.Create(); m_DataAccess = (ISilDataAccess)m_CacheDa; // So many things blow up so badly if we don't have one of these that I finally decided to just // make one, even though it won't always, perhaps not often, be the one we want. m_wsf = LgWritingSystemFactoryClass.Create(); m_DataAccess.WritingSystemFactory = WritingSystemFactory; this.VScroll = true; this.AutoScroll = true; }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Cleanup managed stuff here. if (m_cacheDa != null) m_cacheDa.ClearAllData(); } // Cleanup unmanaged stuff here. m_dataAccess = null; if (m_cacheDa != null) { if (Marshal.IsComObject(m_cacheDa)) Marshal.ReleaseComObject(m_cacheDa); m_cacheDa = null; } m_owner = null; // It will get disposed on its own, if it hasn't been already. m_vc = null; base.Dispose(disposing); }
public void IsHighlighted_CollectionWithSingleElement_ReturnsTrue() { using (var listBox = new FwListBox()) { using (var innerFwListBox = new InnerFwListBox(listBox)) { ITsString testString1 = TsStringHelper.MakeTSS("test1", m_hvoEnglishWs); listBox.Items.Add(testString1); innerFwListBox.MakeRoot(); listBox.HighlightedIndex = 0; // The Test Assert.AreEqual(true, innerFwListBox.IsHighlighted(0)); } } }
public void IsHighlighted_EmptyFwListBox_ReturnsFalse() { using (var listBox = new FwListBox()) { using (var innerFwListBox = new InnerFwListBox(listBox)) { // The Test Assert.AreEqual(false, innerFwListBox.IsHighlighted(0)); } } }
public void SetShowHighlight_EmptyFwListBox_ShouldBeSetToFalse() { using (var listBox = new FwListBox()) { using (var innerFwListBox = new InnerFwListBox(listBox)) { // The Test innerFwListBox.ShowHighlight = false; Assert.AreEqual(false, innerFwListBox.ShowHighlight); } } }
public void ShowHighlight_EmptyFwListBox_ReturnsTrue() { using (var listBox = new FwListBox()) { using (var innerFwListBox = new InnerFwListBox(listBox)) { // The Test Assert.AreEqual(true, innerFwListBox.ShowHighlight); } } }
public void WritingSystemCode_EmptyFwListBox_DoesNotThrowException() { using (var listBox = new FwListBox()) { using (var innerFwListBox = new InnerFwListBox(listBox)) { // The Test Assert.GreaterOrEqual(innerFwListBox.WritingSystemCode, 0); } } }
public void SetIndex_CollectionWithSingleElement_ValueShouldHaveChanged() { using (var listBox = new FwListBox()) { using (var collection = new FwListBox.ObjectCollection(listBox)) { ITsString testString1 = TsStringHelper.MakeTSS("test1", m_hvoEnglishWs); ITsString testString2 = TsStringHelper.MakeTSS("test2", m_hvoEnglishWs); collection.Add(testString1); // The Test collection[0] = testString2; Assert.AreEqual(1, collection.Count); Assert.IsFalse(collection.Contains(testString1)); Assert.IsTrue(collection.Contains(testString2)); } } }