source: trunk/TestCase/SimpleTestCase/SerializeTest.ab@ 465

Last change on this file since 465 was 465, checked in by dai, 16 years ago

ActiveBasic.Xml.Parserを仮実装。
・SerializeTestのテストケースを追加。
・SimpleTestCaseにおいて、一時ディレクトリを扱えるようにした。
・XmlTestのテストケースを更新。

File size: 1.2 KB
Line 
1Namespace SerializeTest
2
3Class Foo
4 a As Long
5 b As Long
6 c As Long
7 d As Long
8Public
9 Sub Foo()
10 a=100
11 b=200
12 c=300
13 d=400
14 End Sub
15End Class
16
17Sub TestMain()
18 ' 一時ディレクトリを取得
19 Dim tempDir = GetExclusiveTempDirPath( "SerializeTest" )
20
21 ' fooインスタンスを生成
22 Dim foo = New Foo
23
24
25 '----------------------------------------------------------------
26 ' シリアライズ
27 '----------------------------------------------------------------
28
29 ' 保存先のファイルを開いて、
30 Dim fooXmlFilePath = tempDir + "\foo.xml"
31 Dim fs = New System.IO.FileStream( fooXmlFilePath, System.IO.FileMode.Create )
32
33 ' シリアライズして、
34 Dim serializer = New System.Xml.Serialization.XmlSerializer( foo.GetType() )
35 serializer.Serialize( fs, foo )
36
37 ' 閉じる。
38 fs.Close()
39
40
41 '----------------------------------------------------------------
42 ' デシリアライズ
43 '----------------------------------------------------------------
44
45 ' 読み込んでみる。
46 Dim doc = New System.Xml.XmlDocument
47 doc.Load( tempDir + "\foo.xml" )
48 System.Diagnostics.Debug.WriteLine( doc.OuterXml )
49
50 ' TODO: デシリアライズは未完成( ̄□ ̄;)
51End Sub
52
53
54End Namespace
55
56SerializeTest.TestMain()
Note: See TracBrowser for help on using the repository browser.