コード例 #1
0
ファイル: VectorTests.cs プロジェクト: sillsdev/WorldPad
        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);
            }
        }
コード例 #2
0
		/// <summary>
		/// Creates a new record with the specified notebook as the owner.
		/// </summary>
		/// <param name="notebook">The notebook.</param>
		/// <param name="title">The title.</param>
		/// <param name="type">The type.</param>
		/// <returns></returns>
		public IRnGenericRec Create(IRnResearchNbk notebook, ITsString title, ICmPossibility type)
		{
			return Create(notebook.RecordsOC, title, type);
		}