示例#1
0
        public void TestTextRepOfObj_InvalidObject()
        {
            CheckDisposed();

            EditingHelper editHelper       = new EditingHelper(null);
            string        sTextRepOfObject = editHelper.TextRepOfObj(m_fdoCache, Guid.Empty);

            Assert.IsNull(sTextRepOfObject);
        }
示例#2
0
        public void TestTextRepOfObj_CmPicture()
        {
            CheckDisposed();

            string internalPathOrig = null;
            string internalPathNew  = null;

            try
            {
                using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
                {
                    ITsStrFactory factory    = TsStrFactoryClass.Create();
                    EditingHelper editHelper = new EditingHelper(null);
                    CmPicture     pict       = new CmPicture(m_fdoCache, filemaker.Filename,
                                                             factory.MakeString("Test picture", m_fdoCache.DefaultVernWs),
                                                             StringUtils.LocalPictures);
                    Assert.IsNotNull(pict);
                    Assert.IsTrue(pict.PictureFileRA.AbsoluteInternalPath == pict.PictureFileRA.InternalPath);
                    Guid   guid             = Cache.GetGuidFromId(pict.Hvo);
                    string sTextRepOfObject = editHelper.TextRepOfObj(m_fdoCache, guid);
                    int    objectDataType;
                    guid = editHelper.MakeObjFromText(m_fdoCache, sTextRepOfObject, null,
                                                      out objectDataType);
                    CmPicture pictNew = new CmPicture(Cache, Cache.GetIdFromGuid(guid));
                    Assert.IsTrue(pict != pictNew);
                    internalPathOrig = pict.PictureFileRA.AbsoluteInternalPath;
                    internalPathNew  = pictNew.PictureFileRA.AbsoluteInternalPath;
                    Assert.AreEqual(internalPathOrig, internalPathNew);
                    Assert.AreEqual(internalPathOrig.IndexOf("junk"), internalPathNew.IndexOf("junk"));
                    Assert.IsTrue(internalPathNew.EndsWith(".jpg"));
                    AssertEx.AreTsStringsEqual(pict.Caption.VernacularDefaultWritingSystem.UnderlyingTsString,
                                               pictNew.Caption.VernacularDefaultWritingSystem.UnderlyingTsString);
                    Assert.AreEqual(pict.PictureFileRA.OwnerHVO, pictNew.PictureFileRA.OwnerHVO);
                }
            }
            finally
            {
                // TODO: When Undo works right, these should get cleaned up automatically
                if (internalPathOrig != null)
                {
                    File.Delete(internalPathOrig);
                }
                if (internalPathNew != null)
                {
                    File.Delete(internalPathNew);
                }
            }
        }
示例#3
0
		public void TestTextRepOfObj_InvalidObject()
		{
			CheckDisposed();

			EditingHelper editHelper = new EditingHelper(null);
			string sTextRepOfObject = editHelper.TextRepOfObj(m_fdoCache, Guid.Empty);
			Assert.IsNull(sTextRepOfObject);
		}
示例#4
0
		public void TestTextRepOfObj_CmPicture()
		{
			CheckDisposed();

			string internalPathOrig = null;
			string internalPathNew = null;
			try
			{
				using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
				{
					ITsStrFactory factory = TsStrFactoryClass.Create();
					EditingHelper editHelper = new EditingHelper(null);
					CmPicture pict = new CmPicture(m_fdoCache, filemaker.Filename,
						factory.MakeString("Test picture", m_fdoCache.DefaultVernWs),
						StringUtils.LocalPictures);
					Assert.IsNotNull(pict);
					Assert.IsTrue(pict.PictureFileRA.AbsoluteInternalPath == pict.PictureFileRA.InternalPath);
					Guid guid = Cache.GetGuidFromId(pict.Hvo);
					string sTextRepOfObject = editHelper.TextRepOfObj(m_fdoCache, guid);
					int objectDataType;
					guid = editHelper.MakeObjFromText(m_fdoCache, sTextRepOfObject, null,
						out objectDataType);
					CmPicture pictNew = new CmPicture(Cache, Cache.GetIdFromGuid(guid));
					Assert.IsTrue(pict != pictNew);
					internalPathOrig = pict.PictureFileRA.AbsoluteInternalPath;
					internalPathNew = pictNew.PictureFileRA.AbsoluteInternalPath;
					Assert.AreEqual(internalPathOrig, internalPathNew);
					Assert.AreEqual(internalPathOrig.IndexOf("junk"), internalPathNew.IndexOf("junk"));
					Assert.IsTrue(internalPathNew.EndsWith(".jpg"));
					AssertEx.AreTsStringsEqual(pict.Caption.VernacularDefaultWritingSystem.UnderlyingTsString,
						pictNew.Caption.VernacularDefaultWritingSystem.UnderlyingTsString);
					Assert.AreEqual(pict.PictureFileRA.OwnerHVO, pictNew.PictureFileRA.OwnerHVO);
				}
			}
			finally
			{
				// TODO: When Undo works right, these should get cleaned up automatically
				if (internalPathOrig != null)
					File.Delete(internalPathOrig);
				if (internalPathNew != null)
					File.Delete(internalPathNew);
			}
		}