SVCS - English Documentation
Loading...
Searching...
No Matches
MockHelpServiceAdapter.hxx
1#pragma once
2
3#include <memory>
4#include <string>
5#include <vector>
6#include <functional>
9#include "MockHelpService.hxx"
10
11namespace svcs::test::cli::mocks {
12
16class MockHelpServiceAdapter : public svcs::cli::HelpService {
17private:
18 std::shared_ptr<MockHelpService> mockHelpService_;
19
20public:
21 explicit MockHelpServiceAdapter(std::shared_ptr<MockHelpService> mockHelpService)
23 // 1. bus - nullptr, так как MockHelpService сам отправляет события
24 nullptr,
25 // 2. Коллбэк для получения доступных команд
26 [this]() -> std::vector<std::string> {
27 return mockHelpService_->getAvailableCommands();
28 },
29 // 3. Коллбэк для получения описания команды
30 [this](const std::string& commandName) -> std::string {
31 return mockHelpService_->getCommandDescription(commandName);
32 },
33 // 4. Коллбэк для показа справки по команде
34 [this](const std::string& commandName) {
35 mockHelpService_->showCommandHelp(commandName);
36 },
37 // 5. Коллбэк для получения использования команды
38 [this](const std::string& commandName) -> std::string {
39 // Простая реализация или делегируем mock
40 return "Usage: svcs " + commandName + " [options]";
41 }
42 ),
43 mockHelpService_(mockHelpService) {
44 }
45
46 // Методы доступа к mock для тестов
47 std::shared_ptr<MockHelpService> getMock() const {
48 return mockHelpService_;
49 }
50};
51
52} // namespace svcs::test::cli::mocks
Defines the event structure used for the Observer pattern notifications.
Service for providing help information about commands.
Mock implementation of the HelpService interface for unit testing purposes.
Service that provides help information for commands.
Definition HelpService.hxx:38
HelpService(std::shared_ptr< ISubject > bus, std::function< std::vector< std::string >()> getCommands, std::function< std::string(const std::string &)> getDescription, std::function< void(const std::string &)> showHelp, std::function< std::string(const std::string &)> getUsage=nullptr)
Constructs the HelpService by injecting necessary dependencies as callbacks.
Definition HelpService.cxx:22
Mock objects and test doubles for CLI command testing.