mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-02 09:49:48 +02:00
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#include "WinServiceTest.h"
|
|
#include "CppUnit/TestCaller.h"
|
|
#include "CppUnit/TestSuite.h"
|
|
|
|
using Poco::Util::WinService;
|
|
|
|
|
|
WinServiceTest::WinServiceTest(const std::string& name) : CppUnit::TestCase(name) {
|
|
}
|
|
|
|
|
|
WinServiceTest::~WinServiceTest() {
|
|
}
|
|
|
|
|
|
void WinServiceTest::testServiceCouldCreatedWithExistingConnection() {
|
|
|
|
SC_HANDLE scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
|
|
|
assertTrue(scmHandle);
|
|
|
|
WinService spoolerService{ scmHandle, "Spooler" };
|
|
|
|
assertTrue(spoolerService.isRegistered());
|
|
}
|
|
|
|
void WinServiceTest::testServiceReturnsTrueIfStopped() {
|
|
spoolerService_.stop();
|
|
assertTrue(spoolerService_.isStopped());
|
|
}
|
|
|
|
|
|
void WinServiceTest::setUp() {
|
|
}
|
|
|
|
|
|
void WinServiceTest::tearDown() {
|
|
if (spoolerService_.isStopped()) {
|
|
spoolerService_.start();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
CppUnit::Test* WinServiceTest::suite() {
|
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("WinServiceTest");
|
|
|
|
CppUnit_addTest(pSuite, WinServiceTest, testServiceCouldCreatedWithExistingConnection);
|
|
CppUnit_addTest(pSuite, WinServiceTest, testServiceReturnsTrueIfStopped);
|
|
|
|
return pSuite;
|
|
}
|