public void does_not_set_variable_not_matching_regex() { var path = Path.GetTempFileName(); File.WriteAllText(path, @"[foo] bar = hi baz = bye"); ConfigDocument .FromFile(path) .Set("foo", null, "baz", "hi", ValueMatcher.From("blah")) .Save(); var saved = ConfigDocument.FromFile(path); Assert.Equal("bye", saved.Where(x => x.Variable == "baz").First().RawValue); }
public void can_set_all_variables_matching_regex() { var path = Path.GetTempFileName(); File.WriteAllText(path, @"[foo] source = github.com/kzu source = microsoft.com/kzu source = github.com/vga source = microsoft.com/vga"); ConfigDocument .FromFile(path) .SetAll("foo", null, "source", "none", ValueMatcher.From("github\\.com")) .Save(); var saved = ConfigDocument.FromFile(path); Assert.Equal(2, saved.Where(x => x.RawValue == "none").Count()); }