SVCS - English Documentation
Loading...
Searching...
No Matches
ClearCommandTest.hxx
Go to the documentation of this file.
1
19#pragma once
20
24
25#include <gtest/gtest.h>
26#include <sstream>
27
43namespace svcs::test::cli::utils {
44
45using namespace svcs::test::cli::mocks;
47using namespace svcs::core;
48using namespace svcs::cli;
49
67class ClearCommandTest : public ::testing::Test {
68protected:
76 std::shared_ptr<MockSubject> mockEventBus;
77
85 std::shared_ptr<RepositoryManager> repoManager;
86
94 std::unique_ptr<ClearCommand> command;
95
103 std::filesystem::path testDir;
104
112 std::stringstream inputStream;
113
121 std::streambuf* originalCin;
122
127
132 void SetUp() override;
133
143 void TearDown() override;
144
156 void createTestFile(const std::string& filename, const std::string& content = "test content") const;
157
167 void createTestDirectory(const std::string& dirname) const;
168
178 void simulateUserInput(const std::string& input);
179
189 bool repositoryExists() const;
190};
191
192}
Declaration of the ClearCommand class for removing SVCS repository.
Declaration of the RepositoryManager class, managing all repository-level file operations.
Test fixture for ClearCommand integration tests.
Definition ClearCommandTest.hxx:46
std::filesystem::path testDir
Path to the temporary directory used as the repository root.
Definition ClearCommandTest.hxx:70
void createTestFile(const std::string &filename, const std::string &content="test content") const
Creates a test file inside the test directory.
Definition ClearCommandTest.cxx:51
std::shared_ptr< RepositoryManager > repoManager
Real RepositoryManager instance under test.
Definition ClearCommandTest.hxx:58
std::stringstream inputStream
String stream used to feed simulated input to std::cin.
Definition ClearCommandTest.hxx:76
std::streambuf * originalCin
Pointer to the original buffer of std::cin, saved for restoration.
Definition ClearCommandTest.hxx:82
void createTestDirectory(const std::string &dirname) const
Creates a test directory inside the test directory.
Definition ClearCommandTest.cxx:60
void simulateUserInput(const std::string &input)
Simulates user input by redirecting std::cin to a string stream.
Definition ClearCommandTest.cxx:64
std::shared_ptr< MockSubject > mockEventBus
Mock event bus for capturing system notifications.
Definition ClearCommandTest.hxx:52
void SetUp() override
Sets up the test environment.
Definition ClearCommandTest.cxx:19
std::unique_ptr< ClearCommand > command
ClearCommand instance under test.
Definition ClearCommandTest.hxx:64
void TearDown() override
Tears down the test environment.
Definition ClearCommandTest.cxx:37
bool repositoryExists() const
Checks if the .svcs repository directory exists.
Definition ClearCommandTest.cxx:70
Mock implementation of the ISubject interface for unit testing purposes.
Command-line interface components and command implementations.
Core VCS data structures and object model.
Utility classes and test fixtures for CLI command testing.
Definition ClearCommandTest.cxx:17