public void ReturnValues() { var source = new CommandLineSource(new[] { "--property", "23" }); source.TryGet(out var result).Should().BeTrue(); result.Should().NotBeNull(); }
public void PropertiesAreCorrectlyParsed() { string[] args = new string[] { "--test.property=123", "" }; var commandLineSource = new CommandLineSource(args); string value; Assert.IsTrue(commandLineSource.TryGetString("test.property", out value)); Assert.AreEqual("123", value); }
public void PropertyValuesMayContainSpaces() { string[] args = new string[] { "--test.property=test string property with spaces", "" }; var commandLineSource = new CommandLineSource(args); string value; Assert.IsTrue(commandLineSource.TryGetString("test.property", out value)); Assert.AreEqual("test string property with spaces", value); }
private IConfigurationSource GetConfigurationSource() { var configurationSource = new CommandLineSource(commandLineArguments) .CombineWith(new JsonFileSource("appsettings.json")) .CombineWith(new JsonFileSource("appsettings." + (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production") + ".json")); var environmentName = Environment.GetEnvironmentVariable("UlearnEnvironmentName"); if (environmentName != null && environmentName.ToLower().Contains("local")) configurationSource = configurationSource.CombineWith(new JsonFileSource("appsettings.local.json")); return configurationSource; }
public void EvaluateNestedValues() { var source = new CommandLineSource(new[] { "boo.foo.value=true" }); source.TryGet(out var jsonObject); var data = ((JsonObject)((JsonObject)jsonObject["boo"])["foo"])["value"]; ((JsonValue)data).Value.Should().Be("true"); }
public void NotReturnValuesIfNullArgs() { var source = new CommandLineSource(null); source.TryGet(out _).Should().BeFalse(); }
public void NotReturnValuesIfEmptyArgs() { var source = new CommandLineSource(Array.Empty <string>()); source.TryGet(out _).Should().BeFalse(); }