83 std::vector<std::string> availableCommands_;
92 std::map<std::string, std::string> commandDescriptions_;
101 std::set<std::string> calledCommandHelp_;
110 std::shared_ptr<MockSubject> mockEventBus_;
119 bool wasGeneralHelpCalled_ =
false;
131 explicit MockHelpService(
const std::shared_ptr<MockSubject>& mockEventBus)
132 : mockEventBus_(mockEventBus) {
147 return availableCommands_;
162 auto it = commandDescriptions_.find(commandName);
163 if (it != commandDescriptions_.end()) {
166 return "No description available";
181 calledCommandHelp_.insert(commandName);
186 event.details =
"MockHelpService: Showing help for " + commandName;
187 event.source_name =
"help";
188 mockEventBus_->notify(event);
202 wasGeneralHelpCalled_ =
true;
207 event.details =
"MockHelpService: Showing general help";
208 event.source_name =
"help";
209 mockEventBus_->notify(event);
225 availableCommands_ = commands;
240 commandDescriptions_[commandName] = description;
255 return calledCommandHelp_.find(commandName) != calledCommandHelp_.end();
268 return wasGeneralHelpCalled_;
279 calledCommandHelp_.clear();
280 availableCommands_.clear();
281 commandDescriptions_.clear();
282 wasGeneralHelpCalled_ =
false;
Defines the event structure used for the Observer pattern notifications.
bool wasGeneralHelpCalled() const
Checks if showGeneralHelp() was called.
Definition MockHelpService.hxx:187
bool wasCommandHelpCalled(const std::string &commandName) const
Checks if showCommandHelp() was called for a specific command.
Definition MockHelpService.hxx:178
void clear()
Resets the mock's internal state (called commands, lists, and descriptions).
Definition MockHelpService.hxx:195
void setAvailableCommands(const std::vector< std::string > &commands)
Sets the list of command names to be returned by getAvailableCommands().
Definition MockHelpService.hxx:158
void showCommandHelp(const std::string &commandName)
Records that help was requested for the given command.
Definition MockHelpService.hxx:122
void showGeneralHelp()
Records that general help was requested.
Definition MockHelpService.hxx:139
std::vector< std::string > getAvailableCommands() const
Returns the pre-configured list of available commands.
Definition MockHelpService.hxx:98
std::string getCommandDescription(const std::string &commandName) const
Returns the pre-configured description for a given command.
Definition MockHelpService.hxx:108
void setCommandDescription(const std::string &commandName, const std::string &description)
Configures a description for a specific command name.
Definition MockHelpService.hxx:168
MockHelpService(const std::shared_ptr< MockSubject > &mockEventBus)
Constructor for MockHelpService.
Definition MockHelpService.hxx:87
Mock implementation of the ISubject interface for unit testing purposes.
Mock objects and test doubles for CLI command testing.
Structure describing an event published by the VCS core.
Definition Event.hxx:30
@ DEBUG_MESSAGE
Debug message for development purposes.
Definition Event.hxx:106
Type type
The type of event that occurred.
Definition Event.hxx:173