SVCS - English Documentation
Loading...
Searching...
No Matches
svcs::test::cli::mocks::MockHelpService Class Reference

A mock implementation of the HelpService for testing the HelpCommand. More...

#include <MockHelpService.hxx>

Public Member Functions

 MockHelpService (const std::shared_ptr< MockSubject > &mockEventBus)
 Constructor for MockHelpService.
std::vector< std::string > getAvailableCommands () const
 Returns the pre-configured list of available commands.
std::string getCommandDescription (const std::string &commandName) const
 Returns the pre-configured description for a given command.
void showCommandHelp (const std::string &commandName)
 Records that help was requested for the given command.
void showGeneralHelp ()
 Records that general help was requested.
void setAvailableCommands (const std::vector< std::string > &commands)
 Sets the list of command names to be returned by getAvailableCommands().
void setCommandDescription (const std::string &commandName, const std::string &description)
 Configures a description for a specific command name.
bool wasCommandHelpCalled (const std::string &commandName) const
 Checks if showCommandHelp() was called for a specific command.
bool wasGeneralHelpCalled () const
 Checks if showGeneralHelp() was called.
void clear ()
 Resets the mock's internal state (called commands, lists, and descriptions).

Detailed Description

A mock implementation of the HelpService for testing the HelpCommand.

This mock allows test cases to:

  1. Configure the list of available commands.
  2. Configure the descriptions for specific commands.
  3. Verify which command's help was requested by the HelpCommand.
  4. Use the provided MockSubject for emitting debug information during testing.

Constructor & Destructor Documentation

◆ MockHelpService()

svcs::test::cli::mocks::MockHelpService::MockHelpService ( const std::shared_ptr< MockSubject > & mockEventBus)
inlineexplicit

Constructor for MockHelpService.

Parameters
mockEventBusThe shared pointer to the MockSubject used for notifications.

Member Function Documentation

◆ getAvailableCommands()

std::vector< std::string > svcs::test::cli::mocks::MockHelpService::getAvailableCommands ( ) const
inlinenodiscard

Returns the pre-configured list of available commands.

Returns
A vector of command names.

◆ getCommandDescription()

std::string svcs::test::cli::mocks::MockHelpService::getCommandDescription ( const std::string & commandName) const
inlinenodiscard

Returns the pre-configured description for a given command.

Parameters
commandNameThe name of the command.
Returns
The configured description, or "No description available" if not set.

◆ setAvailableCommands()

void svcs::test::cli::mocks::MockHelpService::setAvailableCommands ( const std::vector< std::string > & commands)
inline

Sets the list of command names to be returned by getAvailableCommands().

Parameters
commandsThe vector of command names.

◆ setCommandDescription()

void svcs::test::cli::mocks::MockHelpService::setCommandDescription ( const std::string & commandName,
const std::string & description )
inline

Configures a description for a specific command name.

Parameters
commandNameThe name of the command.
descriptionThe description to return for that command.

◆ showCommandHelp()

void svcs::test::cli::mocks::MockHelpService::showCommandHelp ( const std::string & commandName)
inline

Records that help was requested for the given command.

Also emits a debug message to the mock event bus.

Parameters
commandNameThe name of the command whose help is requested.

◆ showGeneralHelp()

void svcs::test::cli::mocks::MockHelpService::showGeneralHelp ( )
inline

Records that general help was requested.

Also emits a debug message to the mock event bus.

◆ wasCommandHelpCalled()

bool svcs::test::cli::mocks::MockHelpService::wasCommandHelpCalled ( const std::string & commandName) const
inlinenodiscard

Checks if showCommandHelp() was called for a specific command.

Parameters
commandNameThe name of the command to check.
Returns
true if showCommandHelp() was called with this name, false otherwise.

◆ wasGeneralHelpCalled()

bool svcs::test::cli::mocks::MockHelpService::wasGeneralHelpCalled ( ) const
inlinenodiscard

Checks if showGeneralHelp() was called.

Returns
true if showGeneralHelp() was called, false otherwise.

The documentation for this class was generated from the following file: