SVCS - English Documentation
Loading...
Searching...
No Matches
IntUndoCommandTest.hxx
Go to the documentation of this file.
1
23
24#pragma once
25
26#include <gtest/gtest.h>
27#include <memory>
28#include <vector>
29#include <string>
30#include <filesystem>
31
34
50namespace svcs::test::cli::utils {
51
56
76class UndoCommandTest : public ::testing::Test {
77protected:
87 void SetUp() override;
88
98 void TearDown() override;
99
111 void createTestFile(const std::string& filename, const std::string& content) const;
112
122 void createTestDirectory(const std::string& dirname) const;
123
133 void stageFiles(const std::vector<std::string>& files);
134
148 bool createTestCommit(const std::string& message);
149
163 static bool containsMessage(const std::vector<Event>& notifications, const std::string& message);
164
178 static int countMessages(const std::vector<Event>& notifications, const std::string& message);
179
191 static void simulateUserInput(const std::string& input);
192
200 std::shared_ptr<MockSubject> mockEventBus;
201
209 std::shared_ptr<RepositoryManager> repoManager;
210
218 std::unique_ptr<UndoCommand> command;
219
227 std::filesystem::path testDir;
228};
229
230}
Declaration of the UndoCommand class for reverting changes.
Command to revert the repository state to a previous commit.
Definition UndoCommand.hxx:44
Manages all physical file and directory operations within the SVCS repository.
Definition RepositoryManager.hxx:83
A mock implementation of ISubject for testing event-driven components.
Definition MockSubject.hxx:43
Google Test fixture for running integration tests against the UndoCommand.
Definition IntUndoCommandTest.hxx:52
std::unique_ptr< UndoCommand > command
Unique pointer to the command being tested.
Definition IntUndoCommandTest.hxx:141
bool createTestCommit(const std::string &message)
Creates a new commit (save) with a specified message.
Definition IntUndoCommandTest.cxx:67
std::shared_ptr< MockSubject > mockEventBus
Shared pointer to the mock event bus (observer/input simulator).
Definition IntUndoCommandTest.hxx:129
void SetUp() override
Sets up the testing environment before each test.
Definition IntUndoCommandTest.cxx:24
static bool containsMessage(const std::vector< Event > &notifications, const std::string &message)
Checks if a specific message (substring) exists in any event notification.
Definition IntUndoCommandTest.cxx:72
void createTestDirectory(const std::string &dirname) const
Creates a test directory in the temporary location.
Definition IntUndoCommandTest.cxx:57
static int countMessages(const std::vector< Event > &notifications, const std::string &message)
Counts the occurrences of a specific message (substring) across all event notifications.
Definition IntUndoCommandTest.cxx:79
std::shared_ptr< RepositoryManager > repoManager
Shared pointer to the repository core logic component.
Definition IntUndoCommandTest.hxx:135
void stageFiles(const std::vector< std::string > &files)
Stages a list of files using the RepositoryManager's staging logic.
Definition IntUndoCommandTest.cxx:61
std::filesystem::path testDir
Path to the temporary test repository directory.
Definition IntUndoCommandTest.hxx:147
static void simulateUserInput(const std::string &input)
Simulates user input by pushing the string into the mock event bus's input queue.
Definition IntUndoCommandTest.cxx:86
void TearDown() override
Tears down the testing environment after each test.
Definition IntUndoCommandTest.cxx:45
void createTestFile(const std::string &filename, const std::string &content) const
Creates a test file with specified content in the temporary directory.
Definition IntUndoCommandTest.cxx:51
Mock implementation of the ISubject interface for unit testing purposes.
Utility classes and test fixtures for CLI command testing.
Definition ClearCommandTest.cxx:17
Structure describing an event published by the VCS core.
Definition Event.hxx:30