public void CreateSimpleNoValuesGeneric() { var typedConfiguration = ConfigurationUtilities.CreateFrom <DemoConfiguration>(null, null, null, null, null); Assert.IsNotNull(typedConfiguration, "Configuration unexpected value"); Assert.IsNotNull(typedConfiguration, "Invalid type returned"); Assert.IsNotNull(typedConfiguration.ObjectValue == default, "ObjectValue not expected"); Assert.IsTrue(typedConfiguration.BooleanValue == default, "BooleanValue not expected"); Assert.IsTrue(typedConfiguration.DateTimeValue == default, "DateTimeValue not expected"); Assert.IsTrue(typedConfiguration.IntegerValue == default, "IntegerValue not expected"); Assert.IsTrue(typedConfiguration.EnumerationValue == default, "EnumerationValue not expected"); Assert.IsTrue(typedConfiguration.TimeSpanValue == default, "TimeSpanValue not expected"); Assert.IsTrue(typedConfiguration.StringValue == default, "StringValue not expected"); }
public void CreateSimpleSubdirectoryFileValuesGeneric() { var typedConfiguration = ConfigurationUtilities.CreateFrom <DemoConfiguration>(null, "SimpleConfiguration.json", "configuration", null, null); Assert.IsNotNull(typedConfiguration, "Configuration unexpected value"); Assert.IsNotNull(typedConfiguration, "Invalid type returned"); Assert.IsNotNull(typedConfiguration.ObjectValue == default, "ObjectValue not expected"); Assert.IsTrue(typedConfiguration.BooleanValue == false, "BooleanValue not expected"); Assert.IsTrue(typedConfiguration.IntegerValue == 99, "IntegerValue not expected"); Assert.IsTrue(typedConfiguration.EnumerationValue == DemoType.Simple, "EnumerationValue not expected"); Assert.IsTrue(typedConfiguration.TimeSpanValue == TimeSpan.Parse("16:16:16.1616"), "TimeSpanValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.StringValue, "StringFile1", StringComparison.Ordinal), "StringValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.ObjectValue.StringValue, "SubstringFile1", StringComparison.Ordinal), "ObjectValue::StringValue not expected"); Assert.IsTrue(typedConfiguration.DateTimeValue == DateTime.Parse("2020-09-05 17:05:00.0000"), "DateTimeValue not expected"); }
public void CreateSimpleRootFileValuesGeneric() { var typedConfiguration = ConfigurationUtilities.CreateFrom <DemoConfiguration>(null, "SimpleConfigurationRoot.json", null, null, null); Assert.IsNotNull(typedConfiguration, "Configuration unexpected value"); Assert.IsNotNull(typedConfiguration, "Invalid type returned"); Assert.IsNotNull(typedConfiguration.ObjectValue == default, "ObjectValue not expected"); Assert.IsTrue(typedConfiguration.BooleanValue == true, "BooleanValue not expected"); Assert.IsTrue(typedConfiguration.IntegerValue == 88, "IntegerValue not expected"); Assert.IsTrue(typedConfiguration.TimeSpanValue == TimeSpan.Parse("17:17:17.1717"), "TimeSpanValue not expected"); Assert.IsTrue(typedConfiguration.EnumerationValue == DemoType.Complex, "EnumerationValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.StringValue, "StringFile2", StringComparison.Ordinal), "StringValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.ObjectValue.StringValue, "SubstringFile2", StringComparison.Ordinal), "ObjectValue::StringValue not expected"); Assert.IsTrue(typedConfiguration.DateTimeValue == DateTime.Parse("2020-10-17 17:05:00.0000"), "DateTimeValue not expected"); }
public void CreateSimpleCommandLineValuesGeneric() { var commandLine = GetSimpleCommandLine(); var typedConfiguration = ConfigurationUtilities.CreateFrom <DemoConfiguration>(null, null, null, commandLine, null); Assert.IsNotNull(typedConfiguration, "Configuration unexpected value"); Assert.IsNotNull(typedConfiguration, "Invalid type returned"); Assert.IsNotNull(typedConfiguration.ObjectValue == default, "ObjectValue not expected"); Assert.IsTrue(typedConfiguration.BooleanValue == true, "BooleanValue not expected"); Assert.IsTrue(typedConfiguration.IntegerValue == 53, "IntegerValue not expected"); Assert.IsTrue(typedConfiguration.EnumerationValue == DemoType.Complex, "EnumerationValue not expected"); Assert.IsTrue(typedConfiguration.TimeSpanValue == TimeSpan.Parse("01:03:04.4567"), "TimeSpanValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.StringValue, "StringValueCommand", StringComparison.Ordinal), "StringValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.ObjectValue.StringValue, "SubstringCommand", StringComparison.Ordinal), "ObjectValue::StringValue not expected"); Assert.IsTrue(typedConfiguration.DateTimeValue == DateTime.Parse("2020-09-01 14:00:00.0000"), "DateTimeValue not expected"); }
public void CreateSimpleMemoryValuesGeneric() { var memory = GetSimpleDictionary(); var typedConfiguration = ConfigurationUtilities.CreateFrom <DemoConfiguration>(null, null, null, null, memory); Assert.IsNotNull(typedConfiguration, "Configuration unexpected value"); Assert.IsNotNull(typedConfiguration, "Invalid type returned"); Assert.IsNotNull(typedConfiguration.ObjectValue == default, "ObjectValue not expected"); Assert.IsTrue(typedConfiguration.BooleanValue == false, "BooleanValue not expected"); Assert.IsTrue(typedConfiguration.IntegerValue == 42, "IntegerValue not expected"); Assert.IsTrue(typedConfiguration.TimeSpanValue == TimeSpan.Parse("01:02:03.4567"), "TimeSpanValue not expected"); Assert.IsTrue(typedConfiguration.EnumerationValue == DemoType.Simple, "EnumerationValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.StringValue, "StringValueMemory", StringComparison.Ordinal), "StringValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.ObjectValue.StringValue, "SubstringMemory", StringComparison.Ordinal), "ObjectValue::StringValue not expected"); Assert.IsTrue(typedConfiguration.DateTimeValue == DateTime.Parse("2020-09-01 13:00:00.0000"), "DateTimeValue not expected"); }
public void CreateSimpleJsonValuesGeneric() { var json = GetSimpleJson(); var typedConfiguration = ConfigurationUtilities.CreateFrom <DemoConfiguration>(json, null, null, null, null); Assert.IsNotNull(typedConfiguration, "Configuration unexpected value"); Assert.IsNotNull(typedConfiguration, "Invalid type returned"); Assert.IsNotNull(typedConfiguration.ObjectValue == default, "ObjectValue not expected"); Assert.IsTrue(typedConfiguration.BooleanValue == true, "BooleanValue not expected"); Assert.IsTrue(typedConfiguration.IntegerValue == 23, "IntegerValue not expected"); Assert.IsTrue(typedConfiguration.TimeSpanValue == TimeSpan.FromMinutes(123), "TimeSpanValue not expected"); Assert.IsTrue(typedConfiguration.EnumerationValue == DemoType.Complex, "EnumerationValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.StringValue, "StringValueJson", StringComparison.Ordinal), "StringValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.ObjectValue.StringValue, "SubstringJson", StringComparison.Ordinal), "ObjectValue::StringValue not expected"); Assert.IsTrue(typedConfiguration.DateTimeValue == DateTime.Parse("2020-09-01 12:00:00.0000"), "DateTimeValue not expected"); }
public void CreateMemoryAndFileAndCommandLineAndJsonMixedValuesGeneric() { var memory = GetSparseDictionary(); var commandLine = GetSparseCommandLine(); var json = GetSparseJson(); var typedConfiguration = ConfigurationUtilities.CreateFrom <DemoConfiguration>(json, "SparseConfiguration.json", "configuration", commandLine, memory); Assert.IsNotNull(typedConfiguration, "Configuration unexpected value"); Assert.IsNotNull(typedConfiguration, "Invalid type returned"); Assert.IsNotNull(typedConfiguration.ObjectValue == default, "ObjectValue not expected"); Assert.IsTrue(typedConfiguration.BooleanValue == true, "BooleanValue not expected"); Assert.IsTrue(typedConfiguration.IntegerValue == 72, "IntegerValue not expected"); Assert.IsTrue(typedConfiguration.TimeSpanValue == TimeSpan.Parse("16:16:16.1616"), "TimeSpanValue not expected"); Assert.IsTrue(typedConfiguration.EnumerationValue == DemoType.Simple, "EnumerationValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.StringValue, "StringValueMemory", StringComparison.Ordinal), "StringValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.ObjectValue.StringValue, "SubstringMemory", StringComparison.Ordinal), "ObjectValue::StringValue not expected"); Assert.IsTrue(typedConfiguration.DateTimeValue == DateTime.Parse("2020-09-01 14:00:00.0000"), "DateTimeValue not expected"); }
public void CreateMemoryAndFileAndCommandLineAndJsonValues() { var memory = GetSimpleDictionary(); var commandLine = GetSimpleCommandLine(); var json = GetSimpleJson(); var configuration = ConfigurationUtilities.CreateFrom(typeof(DemoConfiguration), json, "SimpleConfigurationRoot.json", null, commandLine, memory); var typedConfiguration = configuration as DemoConfiguration; Assert.IsNotNull(configuration, "Configuration unexpected value"); Assert.IsNotNull(typedConfiguration, "Invalid type returned"); Assert.IsNotNull(typedConfiguration.ObjectValue == default, "ObjectValue not expected"); Assert.IsTrue(typedConfiguration.BooleanValue == true, "BooleanValue not expected"); Assert.IsTrue(typedConfiguration.IntegerValue == 23, "IntegerValue not expected"); Assert.IsTrue(typedConfiguration.TimeSpanValue == TimeSpan.FromMinutes(123), "TimeSpanValue not expected"); Assert.IsTrue(typedConfiguration.EnumerationValue == DemoType.Complex, "EnumerationValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.StringValue, "StringValueJson", StringComparison.Ordinal), "StringValue not expected"); Assert.IsTrue(string.Equals(typedConfiguration.ObjectValue.StringValue, "SubstringJson", StringComparison.Ordinal), "ObjectValue::StringValue not expected"); Assert.IsTrue(typedConfiguration.DateTimeValue == DateTime.Parse("2020-09-01 12:00:00.0000"), "DateTimeValue not expected"); }