OSDN Git Service

読み書き系のテストが漏れてた
authortest <test@yahoo.co.jp>
Tue, 5 Feb 2019 11:11:40 +0000 (20:11 +0900)
committertest <test@yahoo.co.jp>
Tue, 5 Feb 2019 11:11:40 +0000 (20:11 +0900)
WPF/UnitTest/DocumentTest.cs

index 534c64f..7f7ffbd 100644 (file)
@@ -453,6 +453,28 @@ namespace UnitTest
             Assert.AreEqual(false, called);
         }
 
+        [TestMethod]
+        public void SaveAndLoadFile()
+        {
+            const string content = "aaaa";
+            Document doc = new Document();
+            doc.Append(content);
+
+            System.IO.StreamWriter sw = new System.IO.StreamWriter("test.txt");
+            System.Threading.Tasks.Task t = doc.SaveAsync(sw);
+            t.Wait();
+            sw.Close();
+
+            doc.Clear();
+
+            System.IO.StreamReader sr = new System.IO.StreamReader("test.txt");
+            t = doc.LoadAsync(sr);
+            t.Wait();
+            sr.Close();
+
+            Assert.AreEqual(content, doc.ToString(0));
+        }
+
         void AreEqual<T>(IEnumerable<T> t1, IEnumerable<T> t2)
         {
             Assert.AreEqual(t1.Count(), t2.Count());