+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.
}
#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 ()
{
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
}
}