コード例 #1
0
        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);
        }
コード例 #4
0
ファイル: EnvironmentSetup.cs プロジェクト: samstikhin/Ulearn
		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;
		}
コード例 #5
0
        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");
        }
コード例 #6
0
        public void NotReturnValuesIfNullArgs()
        {
            var source = new CommandLineSource(null);

            source.TryGet(out _).Should().BeFalse();
        }
コード例 #7
0
        public void NotReturnValuesIfEmptyArgs()
        {
            var source = new CommandLineSource(Array.Empty <string>());

            source.TryGet(out _).Should().BeFalse();
        }