Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public SettingsProperty(
throw new NotSupportedException(Obsoletions.BinaryFormatterMessage);
}
}
else
{
SerializeAs = serializeAs;
}
Attributes = attributes;
ThrowOnErrorDeserializing = throwOnErrorDeserializing;
ThrowOnErrorSerializing = throwOnErrorSerializing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<Compile Include="System\Configuration\SettingsManageabilityAttributeTests.cs" />
<Compile Include="System\Configuration\SettingsPropertyIsReadOnlyExceptionTests.cs" />
<Compile Include="System\Configuration\SettingsPropertyNotFoundExceptionTests.cs" />
<Compile Include="System\Configuration\SettingsPropertyTests.cs" />
<Compile Include="System\Configuration\SettingsPropertyWrongTypeExceptionTests.cs" />
<Compile Include="System\Configuration\SmokeTest.cs" />
<Compile Include="System\Configuration\StringUtilTests.cs" />
Expand All @@ -93,7 +94,7 @@
<Compile Include="System\Configuration\UrlPathTests.cs" />
<Compile Include="System\Configuration\ValidatiorUtilsTests.cs" />
<Compile Include="System\Diagnostics\DiagnosticsTestData.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
<Compile Include="System\Diagnostics\TraceSourceConfigurationTests.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
<Compile Include="System\Diagnostics\TraceSourceConfigurationTests.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
<Compile Include="System\Drawing\Configuration\SystemDrawingSectionTests.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Configuration;
using Xunit;

namespace System.ConfigurationTests
{
public class SettingsPropertyTests
{
[Fact]
public void SettingsProperty_WithNoArguments()
{
var settingsProperty = new SettingsProperty("TestName");
Assert.Equal("TestName", settingsProperty.Name);
Assert.False(settingsProperty.IsReadOnly);
Assert.Null(settingsProperty.DefaultValue);
Assert.Null(settingsProperty.PropertyType);
Assert.Equal(SettingsSerializeAs.String, settingsProperty.SerializeAs);
Assert.Null(settingsProperty.Provider);
Assert.NotNull(settingsProperty.Attributes);
Assert.False(settingsProperty.ThrowOnErrorDeserializing);
Assert.False(settingsProperty.ThrowOnErrorSerializing);
}

[Theory]
[InlineData(SettingsSerializeAs.String)]
[InlineData(SettingsSerializeAs.Xml)]
[InlineData(SettingsSerializeAs.ProviderSpecific)]
public void SettingsProperty_WithArguments(SettingsSerializeAs serializeAs)
{
var settingsProperty = new SettingsProperty(
"TestName",
typeof(string),
provider: null,
isReadOnly: true,
"TestDefaultValue",
serializeAs,
new SettingsAttributeDictionary(),
throwOnErrorDeserializing: true,
throwOnErrorSerializing: false);
Assert.Equal("TestName", settingsProperty.Name);
Assert.True(settingsProperty.IsReadOnly);
Assert.Equal("TestDefaultValue", settingsProperty.DefaultValue);
Assert.Equal(typeof(string), settingsProperty.PropertyType);
Assert.Equal(serializeAs, settingsProperty.SerializeAs);
Assert.Null(settingsProperty.Provider);
Assert.NotNull(settingsProperty.Attributes);
Assert.True(settingsProperty.ThrowOnErrorDeserializing);
Assert.False(settingsProperty.ThrowOnErrorSerializing);
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.