public void TestTextRepOfObj_InvalidObject() { using (var editHelper = new RootSiteEditingHelper(Cache, null)) { string sTextRepOfObject = editHelper.TextRepOfObj(Cache, Guid.Empty); Assert.IsNull(sTextRepOfObject); } }
public void TestTextRepOfObj_CmPicture() { string internalPathOrig = null; string internalPathNew = null; try { using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true)) { ITsStrFactory factory = TsStrFactoryClass.Create(); using (var editHelper = new RootSiteEditingHelper(Cache, null)) { ICmPicture pict = Cache.ServiceLocator.GetInstance <ICmPictureFactory>().Create( filemaker.Filename, factory.MakeString("Test picture", Cache.DefaultVernWs), CmFolderTags.LocalPictures); Assert.IsNotNull(pict); Assert.IsTrue(pict.PictureFileRA.AbsoluteInternalPath == pict.PictureFileRA.InternalPath); string sTextRepOfObject = editHelper.TextRepOfObj(Cache, pict.Guid); int objectDataType; Guid guid = editHelper.MakeObjFromText(Cache, sTextRepOfObject, null, out objectDataType); ICmPicture pictNew = Cache.ServiceLocator.GetInstance <ICmPictureRepository>().GetObject(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, pictNew.Caption.VernacularDefaultWritingSystem); Assert.AreEqual(pict.PictureFileRA.Owner, pictNew.PictureFileRA.Owner); } } } 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() { string internalPathOrig = null; string internalPathNew = null; try { using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true)) { ITsStrFactory factory = TsStrFactoryClass.Create(); using (var editHelper = new RootSiteEditingHelper(Cache, null)) { ICmPicture pict = Cache.ServiceLocator.GetInstance<ICmPictureFactory>().Create( filemaker.Filename, factory.MakeString("Test picture", Cache.DefaultVernWs), CmFolderTags.LocalPictures); Assert.IsNotNull(pict); Assert.IsTrue(pict.PictureFileRA.AbsoluteInternalPath == pict.PictureFileRA.InternalPath); string sTextRepOfObject = editHelper.TextRepOfObj(Cache, pict.Guid); int objectDataType; Guid guid = editHelper.MakeObjFromText(Cache, sTextRepOfObject, null, out objectDataType); ICmPicture pictNew = Cache.ServiceLocator.GetInstance<ICmPictureRepository>().GetObject(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, pictNew.Caption.VernacularDefaultWritingSystem); Assert.AreEqual(pict.PictureFileRA.Owner, pictNew.PictureFileRA.Owner); } } } finally { // TODO: When Undo works right, these should get cleaned up automatically if (internalPathOrig != null) File.Delete(internalPathOrig); if (internalPathNew != null) File.Delete(internalPathNew); } }