public void TestTextRepOfObj_InvalidObject() { CheckDisposed(); EditingHelper editHelper = new EditingHelper(null); string sTextRepOfObject = editHelper.TextRepOfObj(m_fdoCache, Guid.Empty); Assert.IsNull(sTextRepOfObject); }
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); } } }
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); } }