Normalize line endings.
[mono.git] / mcs / class / System / Test / System.Configuration / ApplicationSettingsBaseTest.cs
index b5a5b21d54b5190b16e362b8a62b31c8cc0b4118..3e3f2a79b6e97cd44ccf6de2ceb0f22f80d2be43 100644 (file)
@@ -27,7 +27,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#define SPEW
+//#define SPEW
 
 #if NET_2_0
 
@@ -150,9 +150,9 @@ namespace MonoTests.System.Configuration {
                public TestSettings4 ()
                        : base ("TestSettings4")
                {
-               }\r
-\r
-               [ApplicationScopedSetting]\r
+               }
+
+               [ApplicationScopedSetting]
                [DefaultSettingValue ("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfString xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n  <string>go</string>\r\n  <string>mono</string>\r\n  </ArrayOfString>")]
                public StringCollection Values {
                        get { return (StringCollection) this ["Values"]; }
@@ -283,9 +283,17 @@ namespace MonoTests.System.Configuration {
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void TestSettings2_Properties ()
                {
+                       // This test will fail when there are newer versions
+                       // of the test assemblies - so conditionalize it in
+                       // such cases.
+#if TARGET_JVM
+                       string expected = "MonoTests.System.Configuration.ProviderPoker, System.Test, Version=0.0.0.0";
+#else
+                       string expected = "MonoTests.System.Configuration.ProviderPoker, System_test_net_2_0, Version=0.0.0.0";
+#endif
+                       Assert.AreEqual (expected, new SettingsProviderAttribute (typeof (ProviderPoker)).ProviderTypeName.Substring (0, expected.Length), "#1");
                        TestSettings2 settings = new TestSettings2 ();
 
                        /* should throw ConfigurationException */
@@ -339,16 +347,42 @@ namespace MonoTests.System.Configuration {
                        public int IntSetting {
                                get { return ((int)(this ["IntSetting"])); }
                        }
-               }\r
-\r
-               [Test]\r
-               public void TestSettings4_StringCollection_DefaultSettingValue ()\r
-               {\r
-                       TestSettings4 settings = new TestSettings4 ();\r
-                       Assert.AreEqual (2, settings.Values.Count, "Count");\r
-                       Assert.AreEqual ("go", settings.Values[0], "0");\r
-                       Assert.AreEqual ("mono", settings.Values[1], "1");\r
                }
+
+               [Test]
+               public void TestSettings4_StringCollection_DefaultSettingValue ()
+               {
+                       TestSettings4 settings = new TestSettings4 ();
+                       Assert.AreEqual (2, settings.Values.Count, "Count");
+                       Assert.AreEqual ("go", settings.Values[0], "0");
+                       Assert.AreEqual ("mono", settings.Values[1], "1");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void Providers ()
+               {
+                       Assert.AreEqual (0, new TestSettings1 ().Providers.Count);
+               }
+
+                class Bug532180 : ApplicationSettingsBase {
+                        [UserScopedSetting]
+                        [DefaultSettingValue("10")]
+                        public int IntSetting {
+                                get { return (int)this["IntSetting"]; }
+                                set { this["IntSetting"] = value; }                               
+                        }
+                }
+
+                [Test] // bug #532180
+                public void DefaultSettingValueAsWithReload() {
+                        Bug532180 settings = new Bug532180();
+                        Assert.AreEqual(10, settings.IntSetting, "A1");
+                        settings.IntSetting = 1;
+                        Assert.AreEqual(1, settings.IntSetting, "A2");
+                        settings.Reload();
+                        Assert.AreEqual(10, settings.IntSetting, "A3");
+                }                        
        }
 }