2010-05-31 Carlos Alberto Cortez <calberto.cortez@gmail.com>
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Mon, 31 May 2010 15:57:12 +0000 (15:57 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Mon, 31 May 2010 15:57:12 +0000 (15:57 -0000)
* IsolatedStorageTest.cs:
* IsolatedStorageFileTest.cs: New tests for AvailableFreeSpace, Quota,
UsedSize and IncreaseQuotaTo.

svn path=/trunk/mcs/; revision=158224

mcs/class/corlib/Test/System.IO.IsolatedStorage/ChangeLog
mcs/class/corlib/Test/System.IO.IsolatedStorage/IsolatedStorageFileTest.cs
mcs/class/corlib/Test/System.IO.IsolatedStorage/IsolatedStorageTest.cs

index 9ba0395a5ec74f35a6d31abf5cd7682bdac47c24..985a5d3073a37c3d078cd58c213d2ff9e96b6586 100644 (file)
@@ -1,3 +1,9 @@
+2010-05-31  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * IsolatedStorageTest.cs:
+       * IsolatedStorageFileTest.cs: New tests for AvailableFreeSpace, Quota,
+       UsedSize and IncreaseQuotaTo.
+
 2010-05-27  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * IsolatedStorageFileTest.cs: New test case for CopyFile.
index 8db7f57c9770e3b22e636e707ef5636fd11892b3..7d53b1a68f2af02b63b15b2edcac11f10e119041 100644 (file)
@@ -503,6 +503,54 @@ namespace MonoTests.System.IO.IsolatedStorageTest {
                }
 
 #if NET_4_0
+               [Test]
+               public void UsedSize ()
+               {
+                       IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
+                       IsolatedStorageFileStream isfs = isf.CreateFile ("file");
+                       StreamWriter writer = new StreamWriter (isfs);
+                       writer.WriteLine ("hello mono");
+                       writer.Close ();
+
+                       Assert.AreEqual (true, isf.UsedSize > 0, "#A0");
+
+                       isf.Close ();
+                       try {
+                               Console.WriteLine (isf.UsedSize);
+                               Assert.Fail ("#Exc1");
+                       } catch (InvalidOperationException) {
+                       }
+
+                       isf.Dispose ();
+                       try {
+                               Console.WriteLine (isf.UsedSize);
+                               Assert.Fail ("#Exc2");
+                       } catch (ObjectDisposedException) {
+                       }
+               }
+
+               [Test]
+               public void IncreateQuotaTo ()
+               {
+                       IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
+
+                       try {
+                               isf.IncreaseQuotaTo (-2);
+                               Assert.Fail ("#Exc1");
+                       } catch (ArgumentException) {
+                       }
+
+                       // I wonder how this behaves on some systems
+                       try {
+                               isf.IncreaseQuotaTo (100);
+                               Assert.Fail ("#Exc2");
+                       } catch (ArgumentException) {
+                       }
+
+                       // Since 'Quota' seems to be returning Int64.MaxValue, we cannot truly test against a value
+                       // larger than that.
+               }
+
                [Test]
                public void DirectoryExists ()
                {
index b4990d8f20af9476bc4c16aa8638ac05de45e031..93f2e87ca957107c04a11016a66920cde78c3789 100644 (file)
@@ -224,5 +224,40 @@ namespace MonoTests.System.IO.IsolatedStorageTest {
                        NonAbstractIsolatedStorage nais = new NonAbstractIsolatedStorage ();
                        ulong ul = nais.MaximumSize;
                }
+
+#if NET_4_0
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void IsolatedStorage_UsedSize ()
+               {
+                       NonAbstractIsolatedStorage nais = new NonAbstractIsolatedStorage ();
+                       Console.WriteLine (nais.UsedSize);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void IsolatedStorage_AvailableFreeSpace ()
+               {
+                       NonAbstractIsolatedStorage nais = new NonAbstractIsolatedStorage ();
+                       Console.WriteLine (nais.AvailableFreeSpace);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void IsolatedStorage_Quota ()
+               {
+                       NonAbstractIsolatedStorage nais = new NonAbstractIsolatedStorage ();
+                       Console.WriteLine (nais.Quota);
+               }
+
+               [Test]
+               public void IsolatedStorage_IncreaseQuotaTo ()
+               {
+                       NonAbstractIsolatedStorage nais = new NonAbstractIsolatedStorage ();
+                       Assert.AreEqual (false, nais.IncreaseQuotaTo (-10), "#A0");
+                       Assert.AreEqual (false, nais.IncreaseQuotaTo (0), "#A1");
+                       Assert.AreEqual (false, nais.IncreaseQuotaTo (100), "#A2");
+               }
+#endif
        }
 }