tests/UTCTask.cpp
void UTCTask::createFiles(int fileCount)
{
    taskName = "Test";
    watchFolder = kWatchFolder;
    watchDepth = -1;
    // Create task object
    CTask task{watchFolder, testTaskAction1, watchDepth, fileCount};
    // Create task object thread and start to watch
    std::unique_ptr<std::thread> taskThread;
    taskThread = std::make_unique<std::thread>(&CTask::monitor, &task);
    filePath = UTCTask::kWatchFolder;
    for (auto cnt01 = 0; cnt01 < fileCount; cnt01++)
    {
        std::stringstream file;
        file << "temp" << cnt01 << ".txt";
        createFile(filePath + file.str());
    }
    // Thread should die after killCount files created
    taskThread->join();
    EXPECT_EQ(fileCount, testTaskAction1->fileCount);
    for (auto cnt01 = 0; cnt01 < fileCount; cnt01++)
    {
        std::stringstream file;
        file << "temp" << cnt01 << ".txt";
        CFile::remove(filePath + file.str());
    }
}
//
// Create fileCount files and check that action function called for each
//
Create fileCount files and check that action function called for each
Create fileCount files and check that action function called for each
void UTCTask::createFiles(int fileCount)
{
    taskName = "Test";
    watchFolder = kWatchFolder;
    watchDepth = -1;
    CTask task{watchFolder, testTaskAction1, watchDepth, fileCount};
     thread and start to watch
    std::unique_ptr<std::thread> taskThread;
    taskThread = std::make_unique<std::thread>(&CTask::monitor, &task);
    filePath = UTCTask::kWatchFolder;
    for (auto cnt01 = 0; cnt01 < fileCount; cnt01++)
    {
        std::stringstream file;
        file << "temp" << cnt01 << ".txt";
        createFile(filePath + file.str());
    }
    taskThread->join();
    EXPECT_EQ(fileCount, testTaskAction1->fileCount);
    for (auto cnt01 = 0; cnt01 < fileCount; cnt01++)
    {
        std::stringstream file;
        file << "temp" << cnt01 << ".txt";
        CFile::remove(filePath + file.str());
    }
}
void UTCTask :: createFiles ( int fileCount ) { taskName = " " ; watchFolder = kWatchFolder ; watchDepth = -1 ; CTask task { watchFolder , testTaskAction1 , watchDepth , fileCount } ; std :: unique_ptr < std :: thread > taskThread ; taskThread = std :: make_unique < std :: thread > ( & CTask :: monitor , & task ) ; filePath = UTCTask :: kWatchFolder ; for ( auto cnt01 = 0 ; cnt01 < fileCount ; cnt01 ++ ) { std :: stringstream file ; file << " " << cnt01 << " " ; createFile ( filePath + file . str ( ) ) ; } taskThread -> join ( ) ; EXPECT_EQ ( fileCount , testTaskAction1 -> fileCount ) ; for ( auto cnt01 = 0 ; cnt01 < fileCount ; cnt01 ++ ) { std :: stringstream file ; file << " " << cnt01 << " " ; CFile :: remove ( filePath + file . str ( ) ) ; } }
Create fileCount files and check that action function called for each
Create fileCount files and check that action function called for each
// Create task object // Create task object thread and start to watch // Thread should die after killCount files created