예제 #1
0
		//TODO: (JDH) fix this so that only an exception *on the last line* will produce a PASS

		// Validity checking in DEBUG mode has been turned off.  It complicates performance testing too much.
		//        [ExpectedException(typeof(ArgumentException))]
		//#if !DEBUG
		//        [Ignore("This test doesn't get an exception in release mode due to CmObject c'tor")]
		//#endif

		//TODO (Steve Miller): The above test fails if the followeng lines are remarked
		// out in CmObject.cs, like below. I have frequently remarked out lines there
		// like this, because they foul up SQL performance tests:
		//
		// (InitExisting method)
		//  //#if DEBUG
		//  //	if (!fcCache.IsDummyObject(hvo))
		//  //		fCheckValidity = true;
		//  //#endif
		//
		// (CreateFromDBObject method)
		// //#if DEBUG
		// //     true/*validity check*/,
		// //#else
		//		false,
		// //#endif

		public void DeleteUnderlyingObject()
		{
			CheckDisposed();

			LexEntry se = new LexEntry();
			m_fdoCache.LangProject.LexDbOA.EntriesOC.Add(se);
			LexSense ls = new LexSense();
			se.SensesOS.Append(ls);
			int khvoLexSense = ls.Hvo;

			ls.DeleteUnderlyingObject();

			Assert.IsTrue(m_fdoCache.VwOleDbDaAccessor.get_ObjOwner(khvoLexSense) <= 0); // khvoLexSense not removed from cache.

			// See if FDO object is valid. It should not be.
			Assert.IsFalse(ls.IsValidObject());

			// Test to see if it is really gone from DB.
			// An exception should be thrown by CmObject.InitExisting,
			// since khvoLexSense isn't in DB now.
			ls = new LexSense(m_fdoCache, khvoLexSense, true, true);
			Assert.IsFalse(ls.IsValidObject());
		}