/// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates 2 fake HF sets for use in testing
        /// </summary>
        /// <returns>the created publication</returns>
        /// ------------------------------------------------------------------------------------
        private IPublication CreateFakeHFSets()
        {
            // create a publication
            IPublication pub = new Publication();

            Cache.LangProject.LexDbOA.PublicationsOC.Add(pub);
            IPubDivision pubDiv = new PubDivision();

            pub.DivisionsOS.Append(pubDiv);

            // create the current HF set for the publication
            pubDiv.HFSetOA = new PubHFSet();
            pubDiv.HFSetOA.DefaultHeaderOA = new PubHeader();
            pubDiv.HFSetOA.DefaultFooterOA = new PubHeader();
            pubDiv.HFSetOA.FirstHeaderOA   = new PubHeader();
            pubDiv.HFSetOA.FirstFooterOA   = new PubHeader();
            pubDiv.HFSetOA.EvenHeaderOA    = new PubHeader();
            pubDiv.HFSetOA.EvenFooterOA    = new PubHeader();
            pubDiv.HFSetOA.Name            = "Test HF Set of Matthew printed in Tabaluga";

            // create a dummy HF set
            IPubHFSet hfset = new PubHFSet();

            m_hfSets.Add(hfset);
            hfset.Name             = "Test HF Set created today";
            hfset.Description.Text = "This is a test HF set";
            hfset.DefaultHeaderOA  = new PubHeader();
            hfset.DefaultFooterOA  = new PubHeader();
            hfset.EvenHeaderOA     = new PubHeader();
            hfset.EvenFooterOA     = new PubHeader();
            hfset.FirstFooterOA    = new PubHeader();
            hfset.FirstHeaderOA    = new PubHeader();
            hfset.DefaultFooterOA.OutsideAlignedText.Text = "outside text";
            hfset.DefaultFooterOA.CenteredText.Text       = "Song of songs";
            hfset.EvenHeaderOA.CenteredText.Text          = "Song even pages";
            hfset.EvenHeaderOA.InsideAlignedText.Text     = "Inside text";
            hfset.FirstFooterOA.InsideAlignedText.Text    = "Inside text";

            // create another dummy HF set
            IPubHFSet hfset2 = new PubHFSet();

            m_hfSets.Add(hfset2);
            hfset2.Name             = "Test HF Set of Matthew printed in Tabaluga";
            hfset2.Description.Text = "This is another test HF set";
            hfset2.DefaultHeaderOA  = new PubHeader();
            hfset2.DefaultFooterOA  = new PubHeader();
            hfset2.EvenHeaderOA     = new PubHeader();
            hfset2.EvenFooterOA     = new PubHeader();
            hfset2.FirstFooterOA    = new PubHeader();
            hfset2.FirstHeaderOA    = new PubHeader();
            hfset2.DefaultHeaderOA.OutsideAlignedText.UnderlyingTsString =
                StringUtils.CreateOrcFromGuid(HeaderFooterVc.PageNumberGuid,
                                              FwObjDataTypes.kodtContextString, Cache.DefaultUserWs);
            hfset2.DefaultFooterOA.CenteredText.Text    = "Matthew";
            hfset2.EvenFooterOA.CenteredText.Text       = "From Reference";
            hfset2.EvenHeaderOA.InsideAlignedText.Text  = "nothing";
            hfset2.FirstFooterOA.InsideAlignedText.Text = "Inside text";

            return(pub);
        }
示例#2
0
		public void MergeGuids()
		{
			CheckDisposed();

			// Use LangProject.Filters.
			FdoOwningCollection<ICmFilter> filtersCol = Cache.LangProject.FiltersOC;
			ICmFilter keeper = filtersCol.Add(new CmFilter());
			ICmFilter src = filtersCol.Add(new CmFilter());

			// Ensure empty (new) guid does not get changed.
			Assert.IsTrue(keeper.App == Guid.Empty);
			src.App = Guid.NewGuid();
			Guid oldSrcGuid = src.App;
			keeper.MergeObject(src);
			Assert.IsTrue(keeper.App == oldSrcGuid);

			// Should not change extant guid in either of the next two checks.
			Guid newGuid = Guid.NewGuid();
			keeper.App = newGuid;
			src = filtersCol.Add(new CmFilter());
			src.App = Guid.NewGuid();
			keeper.MergeObject(src);
			Assert.IsTrue(keeper.App == newGuid);

			src = filtersCol.Add(new CmFilter());
			src.App = Guid.Empty;
			keeper.MergeObject(src);
			Assert.IsTrue(keeper.App == newGuid);
		}
示例#3
0
        public void FdoOwningCollection_AddToOC()
        {
            CheckDisposed();

            FdoOwningCollection <IMoAdhocProhib> oc = Cache.LangProject.MorphologicalDataOA.AdhocCoProhibitionsOC;
            MoAlloAdhocProhib acp = (MoAlloAdhocProhib)oc.Add(new MoAlloAdhocProhib());

            oc.Add(acp);                // Try adding it again.
            // This should work, but it won't actually be moved anywhere.
        }
示例#4
0
        public void VectorRemove_OwningCollection()
        {
            CheckDisposed();

            // Remove an entry from owning collection.
            FdoOwningCollection <ILexEntry> oc = Cache.LangProject.LexDbOA.EntriesOC;

            oc.Add(new LexEntry());
            oc.Add(new LexEntry());
            oc.Add(new LexEntry());

            int[] vhvo = oc.HvoArray;
            oc.Remove(vhvo[1]);

            Assert.AreEqual(2, oc.Count);
        }
示例#5
0
        public void GreaterThanOrEqual()
        {
            // Setup test values
            Cache.LangProject.PeopleOA = new CmPossibilityList();
            ICmPossibility person1 = Cache.LangProject.PeopleOA.PossibilitiesOS.Append(new CmPerson());

            person1.ForeColor = 4;
            ICmPossibility person2 = Cache.LangProject.PeopleOA.PossibilitiesOS.Append(new CmPerson());

            person2.ForeColor = 5;
            ICmPossibility person3 = Cache.LangProject.PeopleOA.PossibilitiesOS.Append(new CmPerson());

            person3.ForeColor = 10;

            // Setup filter
            FdoOwningCollection <ICmFilter> filtersCol = Cache.LangProject.FiltersOC;
            ICmFilter filter = filtersCol.Add(new CmFilter());

            filter.ColumnInfo = CmPossibility.kClassId + "," + (int)CmPossibility.CmPossibilityTags.kflidForeColor;
            ICmRow  row   = filter.RowsOS.Append(new CmRow());
            ICmCell cell1 = row.CellsOS.Append(new DummyCmCell());

            cell1.Contents.Text = ">= 5";

            // Check the result
            ((CmFilter)filter).InitCriteria();
            Assert.IsFalse(((CmFilter)filter).MatchesCriteria(person1.Hvo));
            Assert.IsTrue(((CmFilter)filter).MatchesCriteria(person2.Hvo));
            Assert.IsTrue(((CmFilter)filter).MatchesCriteria(person3.Hvo));
        }
示例#6
0
        public void FdoOwningCollection_AddToOCFromOS()
        {
            CheckDisposed();

            // Now test to see if something can actually be moved.
            // We will use subrecords in a RN object for this.
            // The source flid is a sequence, while the destination is a collection.
            m_inMemoryCache.InitializeDataNotebook();
            IRnResearchNbk rn = Cache.LangProject.ResearchNotebookOA;
            IRnEvent       ev = (IRnEvent)rn.RecordsOC.Add(new RnEvent());

            ev.SubRecordsOS.Append(new RnEvent());
            ev.SubRecordsOS.Append(new RnEvent());
            ev.SubRecordsOS.Append(new RnEvent());

            FdoOwningSequence <IRnGenericRec> os = ev.SubRecordsOS;

            int[] ahvoSrcBefore = (int[])os.HvoArray.Clone();
            FdoOwningCollection <IRnGenericRec> oc = Cache.LangProject.ResearchNotebookOA.RecordsOC;

            int[] ahvoDstBefore = (int[])oc.HvoArray.Clone();
            oc.Add(os.HvoArray);

            // Check data.
            Assert.AreEqual(0, os.HvoArray.Length);                                             // Not empty, so they didn't all get moved.
            Assert.AreEqual((ahvoSrcBefore.Length + ahvoDstBefore.Length), oc.HvoArray.Length); // Not the same size, so they didn't get moved.

            // Make sure everything in ahvoDstBefore is still in cv.HvoArray.
            // If not, then the test failed.
            foreach (int i in ahvoDstBefore)
            {
                bool fFailed = true;
                foreach (int j in oc.HvoArray)
                {
                    if (i == j)
                    {
                        fFailed = false;
                        break;
                    }
                }
                Assert.IsFalse(fFailed);
            }
            // Make sure everything in ahvoSrcBefore made it into cv.HvoArray.
            // If not, then the test failed.
            foreach (int i in ahvoSrcBefore)
            {
                bool fFailed = true;
                foreach (int j in oc.HvoArray)
                {
                    if (i == j)
                    {
                        fFailed = false;
                        break;
                    }
                }
                Assert.IsFalse(fFailed);
            }
        }
示例#7
0
        public void FdoOwningCollection_AddingNull()
        {
            CheckDisposed();

            FdoOwningCollection <IMoAdhocProhib> oc = Cache.LangProject.MorphologicalDataOA.AdhocCoProhibitionsOC;
            // Should throw a null argument exception.
            IMoAdhocProhib p = null;

            oc.Add(p);
        }
示例#8
0
        public void FdoOwningCollection_AddToOC_WithUnownedId()
        {
            CheckDisposed();

            FdoOwningCollection <IMoAdhocProhib> oc = Cache.LangProject.MorphologicalDataOA.AdhocCoProhibitionsOC;
            MoAlloAdhocProhib acp = new MoAlloAdhocProhib();

            // This should fail, since it has an unowned id in the array.
            int[] ahvo = new int[2];
            ahvo[0] = acp.Hvo;
            ahvo[1] = 1;                // Bad ID, since it isn't owned in source flid.
            oc.Add(ahvo);
        }
示例#9
0
		public void MergeUnicode()
		{
			CheckDisposed();

			// 15 CmFilter.Name
			string goodFilter = "Fram";
			string junkFilter = "Brand X";
			FdoOwningCollection<ICmFilter> filtersCol = Cache.LangProject.FiltersOC;
			ICmFilter keeper = filtersCol.Add(new CmFilter());
			ICmFilter src = filtersCol.Add(new CmFilter());

			// Merge content into null original.
			src.Name = goodFilter;
			keeper.MergeObject(src);
			Assert.AreEqual(keeper.Name, goodFilter);

			// Try to merge empty string into null.
			keeper.Name = null;
			src = filtersCol.Add(new CmFilter());
			src.Name = "";
			keeper.MergeObject(src);
			Assert.IsNull(keeper.Name);

			// Try to merge empty string into content.
			keeper.Name = goodFilter;
			src = filtersCol.Add(new CmFilter());
			src.Name = "";
			keeper.MergeObject(src);
			Assert.AreEqual(keeper.Name, goodFilter);

			// Try to merge content into content.
			keeper.Name = goodFilter;
			src = filtersCol.Add(new CmFilter());
			src.Name = junkFilter;
			keeper.MergeObject(src);
			Assert.AreEqual(keeper.Name, goodFilter);

			// Test merge append
			src = filtersCol.Add(new CmFilter());
			src.Name = junkFilter;
			keeper.MergeObject(src, true);
			Assert.AreEqual(keeper.Name, goodFilter +  ' ' + junkFilter);

			// But don't append if equal.
			keeper.Name = goodFilter;
			src = filtersCol.Add(new CmFilter());
			src.Name = goodFilter;
			keeper.MergeObject(src, true);
			Assert.AreEqual(keeper.Name, goodFilter);
		}
示例#10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets a resource matching the specified name from the Owning object from a collection
		/// of resources specified by the field id.
		/// </summary>
		/// <param name="cache">database</param>
		/// <param name="hvoOwner">id of the owning object</param>
		/// <param name="flid">field id in the owning object</param>
		/// <param name="name">name of the specified resource</param>
		/// <param name="newVersion">new version number for the resource</param>
		/// ------------------------------------------------------------------------------------
		public static void SetResource(FdoCache cache, int hvoOwner, int flid, string name,
			Guid newVersion)
		{
			CmResource resource = GetResource(cache, hvoOwner, flid, name);
			if (resource == null)
			{
				// Resource does not exist yet. Add it to the collection.
				FdoOwningCollection<ICmResource> resources =
					new FdoOwningCollection<ICmResource>(cache, hvoOwner, flid);
				CmResource newResource = new CmResource();
				resources.Add(newResource);
				newResource.Name = name;
				newResource.Version = newVersion;
				return;
			}

			resource.Version = newVersion;
		}
示例#11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create a new style and add it to the Language Project stylesheet.
        /// </summary>
        /// <param name="name">style name</param>
        /// <param name="context">style context</param>
        /// <param name="structure">style structure</param>
        /// <param name="function">style function</param>
        /// <param name="isCharStyle">true if character style, otherwise false</param>
        /// <param name="userLevel">The user level.</param>
        /// <param name="styleCollection">The style collection.</param>
        /// <returns>The style</returns>
        /// ------------------------------------------------------------------------------------
        public IStStyle AddTestStyle(string name, ContextValues context, StructureValues structure,
                                     FunctionValues function, bool isCharStyle, int userLevel,
                                     FdoOwningCollection <IStStyle> styleCollection)
        {
            CheckDisposed();
            ITsPropsBldr bldr  = TsPropsBldrClass.Create();
            StStyle      style = new StStyle();

            styleCollection.Add(style);
            style.Name      = name;
            style.Context   = context;
            style.Structure = structure;
            style.Function  = function;
            style.Rules     = bldr.GetTextProps();
            style.Type      = (isCharStyle ? StyleType.kstCharacter : StyleType.kstParagraph);
            style.UserLevel = userLevel;

            return(style);
        }
示例#12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets a resource matching the specified name from the Owning object from a collection
        /// of resources specified by the field id.
        /// </summary>
        /// <param name="cache">database</param>
        /// <param name="hvoOwner">id of the owning object</param>
        /// <param name="flid">field id in the owning object</param>
        /// <param name="name">name of the specified resource</param>
        /// <param name="newVersion">new version number for the resource</param>
        /// ------------------------------------------------------------------------------------
        public static void SetResource(FdoCache cache, int hvoOwner, int flid, string name,
                                       Guid newVersion)
        {
            CmResource resource = GetResource(cache, hvoOwner, flid, name);

            if (resource == null)
            {
                // Resource does not exist yet. Add it to the collection.
                FdoOwningCollection <ICmResource> resources =
                    new FdoOwningCollection <ICmResource>(cache, hvoOwner, flid);
                CmResource newResource = new CmResource();
                resources.Add(newResource);
                newResource.Name    = name;
                newResource.Version = newVersion;
                return;
            }

            resource.Version = newVersion;
        }
示例#13
0
		public void MergeBooleans()
		{
			CheckDisposed();

			// Use LexEntry.ExcludeAsHeadword
			ILexEntry lmeKeeper = m_entriesCol.Add(new LexEntry());
			ILexEntry lmeSrc = m_entriesCol.Add(new LexEntry());

			lmeKeeper.ExcludeAsHeadword = false;
			lmeSrc.ExcludeAsHeadword = false;
			lmeKeeper.MergeObject(lmeSrc);
			Assert.IsFalse(lmeKeeper.ExcludeAsHeadword);

			lmeKeeper.ExcludeAsHeadword = false;
			lmeSrc = m_entriesCol.Add(new LexEntry());
			lmeSrc.ExcludeAsHeadword = true;
			lmeKeeper.MergeObject(lmeSrc);
			Assert.IsTrue(lmeKeeper.ExcludeAsHeadword);

			lmeKeeper.ExcludeAsHeadword = true;
			lmeSrc = m_entriesCol.Add(new LexEntry());
			lmeSrc.ExcludeAsHeadword = true;
			lmeKeeper.MergeObject(lmeSrc);
			Assert.IsTrue(lmeKeeper.ExcludeAsHeadword);

			lmeKeeper.ExcludeAsHeadword = true;
			lmeSrc = m_entriesCol.Add(new LexEntry());
			lmeSrc.ExcludeAsHeadword = false;
			lmeKeeper.MergeObject(lmeSrc);
			Assert.IsTrue(lmeKeeper.ExcludeAsHeadword);
		}
示例#14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new style and add it to the Language Project stylesheet.
		/// </summary>
		/// <param name="name">style name</param>
		/// <param name="context">style context</param>
		/// <param name="structure">style structure</param>
		/// <param name="function">style function</param>
		/// <param name="isCharStyle">true if character style, otherwise false</param>
		/// <param name="userLevel">The user level.</param>
		/// <param name="styleCollection">The style collection.</param>
		/// <returns>The style</returns>
		/// ------------------------------------------------------------------------------------
		public IStStyle AddTestStyle(string name, ContextValues context, StructureValues structure,
			FunctionValues function, bool isCharStyle, int userLevel,
			FdoOwningCollection<IStStyle> styleCollection)
		{
			CheckDisposed();
			ITsPropsBldr bldr = TsPropsBldrClass.Create();
			StStyle style = new StStyle();
			styleCollection.Add(style);
			style.Name = name;
			style.Context = context;
			style.Structure = structure;
			style.Function = function;
			style.Rules = bldr.GetTextProps();
			style.Type = (isCharStyle ? StyleType.kstCharacter : StyleType.kstParagraph);
			style.UserLevel = userLevel;

			return style;
		}