|
| | MockConfiguration () |
| |
template<IsSetting S>
requires (Schema::template has_setting<S>) |
| auto | Get () const -> typename S::value_type |
| | Gets the value for a setting type.
|
| |
template<IsSetting S>
requires (Schema::template has_setting<S>) |
| void | SetValue (typename S::value_type value) |
| | Sets the value for a setting type (bypasses validation for testing).
|
| |
template<IsSetting S>
requires (Schema::template has_setting<S>) |
| auto | Set (typename S::value_type value) -> Status |
| | Sets the value with validation.
|
| |
| auto | Load () -> Status |
| | Simulates loading (no-op for mock).
|
| |
| auto | Save () const -> Status |
| | Simulates saving (no-op for mock).
|
| |
| void | Reset () |
| | Resets all values to defaults.
|
| |
| void | SetRawValue (std::string_view path, Value value) |
| | Sets a raw Value for testing parse failure scenarios.
|
| |
| void | ClearValue (std::string_view path) |
| | Clears a value by path for testing scenarios where key is not found.
|
| |
template<typename Schema>
class cppfig::testing::MockConfiguration< Schema >
Mock implementation of configuration for testing.
This class provides a simple in-memory configuration that can be used in unit tests. It stores values in a map and doesn't require file I/O.
Usage:
struct AppName {
static constexpr std::string_view path = "app.name";
using value_type = std::string;
static auto default_value() -> std::string { return "MyApp"; }
};
struct AppPort {
static constexpr std::string_view path = "app.port";
using value_type = int;
static auto default_value() -> int { return 8080; }
};
using Schema = ConfigSchema<AppName, AppPort>;
MockConfiguration<Schema> config;
config.SetValue<AppPort>(9000);
EXPECT_EQ(config.Get<AppPort>(), 9000);