|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | + |
| 4 | +using System.Configuration; |
| 5 | +using Xunit; |
| 6 | + |
| 7 | +namespace System.ConfigurationTests |
| 8 | +{ |
| 9 | + public class SettingsPropertyTests |
| 10 | + { |
| 11 | + [Fact] |
| 12 | + public void SettingsProperty_WithNoArguments() |
| 13 | + { |
| 14 | + var settingsProperty = new SettingsProperty("TestName"); |
| 15 | + Assert.Equal("TestName", settingsProperty.Name); |
| 16 | + Assert.False(settingsProperty.IsReadOnly); |
| 17 | + Assert.Null(settingsProperty.DefaultValue); |
| 18 | + Assert.Null(settingsProperty.PropertyType); |
| 19 | + Assert.Equal(SettingsSerializeAs.String, settingsProperty.SerializeAs); |
| 20 | + Assert.Null(settingsProperty.Provider); |
| 21 | + Assert.NotNull(settingsProperty.Attributes); |
| 22 | + Assert.False(settingsProperty.ThrowOnErrorDeserializing); |
| 23 | + Assert.False(settingsProperty.ThrowOnErrorSerializing); |
| 24 | + } |
| 25 | + |
| 26 | + [Theory] |
| 27 | + [InlineData(SettingsSerializeAs.String)] |
| 28 | + [InlineData(SettingsSerializeAs.Xml)] |
| 29 | + [InlineData(SettingsSerializeAs.ProviderSpecific)] |
| 30 | + public void SettingsProperty_WithArguments(SettingsSerializeAs serializeAs) |
| 31 | + { |
| 32 | + var settingsProperty = new SettingsProperty( |
| 33 | + "TestName", |
| 34 | + typeof(string), |
| 35 | + provider: null, |
| 36 | + isReadOnly: true, |
| 37 | + "TestDefaultValue", |
| 38 | + serializeAs, |
| 39 | + new SettingsAttributeDictionary(), |
| 40 | + throwOnErrorDeserializing: true, |
| 41 | + throwOnErrorSerializing: false); |
| 42 | + Assert.Equal("TestName", settingsProperty.Name); |
| 43 | + Assert.True(settingsProperty.IsReadOnly); |
| 44 | + Assert.Equal("TestDefaultValue", settingsProperty.DefaultValue); |
| 45 | + Assert.Equal(typeof(string), settingsProperty.PropertyType); |
| 46 | + Assert.Equal(serializeAs, settingsProperty.SerializeAs); |
| 47 | + Assert.Null(settingsProperty.Provider); |
| 48 | + Assert.NotNull(settingsProperty.Attributes); |
| 49 | + Assert.True(settingsProperty.ThrowOnErrorDeserializing); |
| 50 | + Assert.False(settingsProperty.ThrowOnErrorSerializing); |
| 51 | + } |
| 52 | + } |
| 53 | +} |
0 commit comments