Пример #1
0
    public void Load()
    {
        var deserializer = _serializerFactory.CreateDeserializer();
        var settings     = deserializer.Deserialize <SettingsValues?>(LoadOrCreateSettingsFile()) ?? new SettingsValues();

        _settingsProvider.UseSettings(settings);
    }
Пример #2
0
 public ConfigurationLoader(
     IConfigurationProvider configProvider,
     IFileSystem fileSystem,
     IYamlSerializerFactory yamlFactory,
     IValidator <T> validator)
 {
     _configProvider = configProvider;
     _fileSystem     = fileSystem;
     _validator      = validator;
     _deserializer   = yamlFactory.CreateDeserializer();
 }
Пример #3
0
    public void Load_data_correctly_when_file_exists(
        [Frozen(Matching.ImplementedInterfaces)] MockFileSystem fileSystem,
        [Frozen] IYamlSerializerFactory serializerFactory,
        [Frozen] IResourcePaths paths,
        SettingsPersister sut)
    {
        // For this test, it doesn't really matter if the YAML data matches what SettingsValue expects;
        // this test only ensures that the data deserialized is from the actual correct file.
        var expectedYamlData = @"
repository:
  clone_url: http://the_url.com
";
        var deserializer     = Substitute.For <IDeserializer>();

        serializerFactory.CreateDeserializer().Returns(deserializer);
        paths.SettingsPath.Returns("test_path");
        fileSystem.AddFile(paths.SettingsPath, new MockFileData(expectedYamlData));

        sut.Load();

        deserializer.Received().Deserialize <SettingsValues>(expectedYamlData);
    }