00001 00008 #ifndef ORG_PROGGEN_DEDUPE_TEST_TESTENVIRONMENT_H 00009 #define ORG_PROGGEN_DEDUPE_TEST_TESTENVIRONMENT_H 00010 00011 #include <boost/filesystem.hpp> 00012 #include <boost/filesystem/fstream.hpp> 00013 #include <fileinfo/fileinfo.h> 00014 00015 namespace Dedupe 00016 { 00020 namespace Test 00021 { 00025 const std::string SignSource = 00026 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; 00027 00031 const size_t MinSize = 2; 00032 00036 const size_t MaxSize = 20; 00037 00038 00042 const size_t MinParts = 1; 00043 00047 const size_t MaxParts = 10; 00048 00053 class TestEnvironment 00054 { 00055 public: 00062 TestEnvironment( Dedupe::FilePath RootDirectory ); 00063 virtual ~TestEnvironment() {} 00064 00069 size_t CreateRandomInt( size_t Min, size_t Max ); 00070 00076 Dedupe::FilePath CreateRandomPathPart( size_t MinLength, 00077 size_t MaxLength ); 00078 00083 Dedupe::FilePath CreateRandomPathstring(); 00084 00090 Dedupe::FilePath CreateRandomFilename(); 00091 00097 Dedupe::FilePath CreateDirectory( Dedupe::FilePath IncomingPath ); 00098 00106 Dedupe::FilePath CreateFile( Dedupe::FilePath IncomingPath, 00107 Dedupe::FilePath IncomingFilename, 00108 unsigned int FileSize); 00109 00114 void DeleteCreated(); 00115 00119 const Dedupe::FilePath RootDir; 00120 }; 00121 00125 struct TestEnvironmentSelftestFixture 00126 { 00127 TestEnvironmentSelftestFixture() : Env( "selftest" ) {} 00128 virtual ~TestEnvironmentSelftestFixture() 00129 { 00130 Env.DeleteCreated(); 00131 } 00132 Dedupe::Test::TestEnvironment Env; 00133 }; 00134 00135 } 00136 } 00137 00138 #endif