public void WhenConfigUpdated_VariablesAreRetained() { Directory.CreateDirectory("../logs.config"); File.WriteAllText("../logs.config/nlog.web.config", "<nlog xmlns=\"http://www.nlog-project.org/schemas/NLog.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "<variable name=\"name2\" value=\"server_secret\" />" + "</nlog>"); File.WriteAllText("nlog.config", "<nlog xmlns=\"http://www.nlog-project.org/schemas/NLog.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "<variable name=\"name1\" value=\"value1\" />" + "<variable name=\"name2\" value=\"value2\" />" + "<variable name=\"name3\" value=\"value3\" />" + "</nlog>"); var old = DateTime.UtcNow - TimeSpan.FromHours(3); File.SetLastWriteTimeUtc("../logs.config/nlog.web.config", old); var file = LogConfig.PrepareConfigFile(); var values = LogConfig.ReadVariables("../logs.config/nlog.web.config"); values.Should().BeEquivalentTo(new Dictionary <string, string>() { { "name1", "value1" }, { "name2", "server_secret" }, { "name3", "value3" }, }); }