本文整理汇总了C++中Components::Exec方法的典型用法代码示例。如果您正苦于以下问题:C++ Components::Exec方法的具体用法?C++ Components::Exec怎么用?C++ Components::Exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Components
的用法示例。
在下文中一共展示了Components::Exec方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testExecNoCallback
void ComponentsUnitTests::testExecNoCallback()
{
Components components;
CmdComponent * component1 = new CmdComponent();
component1->id = DVLib::GenerateGUIDStringW();
std::wstring check_file = DVLib::DirectoryCombine(DVLib::GetTemporaryDirectoryW(), component1->id);
Assert::IsTrue(! DVLib::FileExists(check_file));
component1->command = L"cmd.exe /C dir > \"" + check_file + L"\"";
components.add(ComponentPtr(component1));
components.Exec(NULL);
Assert::IsTrue(DVLib::FileExists(check_file));
DVLib::FileDelete(check_file);
}
示例2: testExecWithError
void ComponentsUnitTests::testExecWithError()
{
Components components;
CmdComponent * component1 = new CmdComponent();
component1->id = DVLib::GenerateGUIDStringW();
component1->command = L"foobar.exe";
components.add(ComponentPtr(component1));
ExecuteComponentCallbackImpl callback;
components.Exec(& callback);
Assert::IsTrue(1 == callback.starts);
Assert::IsTrue(1 == callback.begins);
Assert::IsTrue(0 == callback.waits);
Assert::IsTrue(0 == callback.successes);
Assert::IsTrue(1 == callback.errors);
}
示例3: testExecWithCallback
void ComponentsUnitTests::testExecWithCallback()
{
Components components;
CmdComponent * component1 = new CmdComponent();
component1->id = DVLib::GenerateGUIDStringW();
std::wstring check_file = DVLib::DirectoryCombine(DVLib::GetTemporaryDirectoryW(), component1->id);
Assert::IsTrue(! DVLib::FileExists(check_file));
component1->command = L"cmd.exe /C dir > \"" + check_file + L"\"";
components.add(ComponentPtr(component1));
ExecuteComponentCallbackImpl callback;
components.Exec(& callback);
Assert::IsTrue(DVLib::FileExists(check_file));
DVLib::FileDelete(check_file);
Assert::IsTrue(1 == callback.starts);
Assert::IsTrue(1 == callback.begins);
Assert::IsTrue(1 == callback.waits);
Assert::IsTrue(1 == callback.successes);
Assert::IsTrue(0 == callback.errors);
}