void TestOnMappedNetworkDrives::ActualTestImportDocument() { DocProviderWorker objWorker; WSDocNonCom wsDoc; LockManager lockMgr; CStdString sMappedDriveLetter = m_NetDriveHelper.GetMapNetworkDriveLetter(); assertMessage(!sMappedDriveLetter.IsEmpty(), _T("Cannot map network drive - used to just skip test")); CStdString sOrigFile = sMappedDriveLetter + _T("\\Original.doc"); DocumentID docImportID(DocumentID::GenerateIdFromFilePath(sOrigFile)); CStdString csLocalFile = docImportID.CreateLocalFile(); objWorker.PopulateDocumentProperties(docImportID, wsDoc, false); CStdString sOldDocID = wsDoc.GetDocId(); HRESULT hrImport = objWorker.ImportDocument(wsDoc, false); assertMessage(SUCCEEDED(hrImport),_T("Failure code returned from ImportDocument()")); if(sOldDocID.CompareNoCase( CStdString(wsDoc.GetDocId()))==0) { assertMessage(false,_T("The in and out DocID's are the same after import")); } // check lock=false CStdString sLockedBy; if(lockMgr.IsDocIDLocked(wsDoc.GetDocId(), sLockedBy) ) { assertMessage(false, _T("Imported file is locked when it was requested not to be")); } if(docImportID.GetDescription() != wsDoc.GetDescription()) { assertMessage(false, _T("The document Description does not match the original file used for the import.")); } assertTest((wsDoc.GetFlags() & DOCUMENT_LOCKED_BY_US)==0); LFSDMSHelper dmsHelp; DocumentID docID(wsDoc.GetDocId()); CStdString sLocalName(docID.GetWorkingFile()); int iFileNameStartsAt = sLocalName.ReverseFind('\\'); if ((iFileNameStartsAt != CStdString::npos) && (dmsHelp.DoesFileExist(sLocalName))) { sLocalName.resize(iFileNameStartsAt); assertTest(dmsHelp.DeleteDirectoryAndContents(sLocalName)); } ::DeleteFile(csLocalFile.c_str()); }
void TestCloseDocument::TestUnlocksFileOnClose() { DocProviderWorker objWorker; WSDocNonCom wsDoc; DocumentID docTarget(DocumentID::GenerateIdFromFilePath(sTestOriginalFileName)); wsDoc.SetDescription(docTarget.GetDescription()); wsDoc.SetLocalFile(docTarget.GetWorkingFile()); assertTest(objWorker.ImportDocument(wsDoc, true) == S_OK); m_wsImportedDoc = wsDoc; assertTest(objWorker.CloseDocument(wsDoc,0) == S_OK); LockManager lckMngr; CStdString sLockedBy; assertTest(lckMngr.IsDocIDLocked(wsDoc.GetDocId(),sLockedBy) == false); }