* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / corlib / Test / System.IO / TextWriterTest.cs
1 //
2 // TextWriterTest.cs
3 //
4 // Author: 
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2004 Novell (http://www.novell.com)
8 //
9
10 using System;
11 using System.Globalization;
12 using System.IO;
13 using System.Text;
14 using NUnit.Framework;
15
16 namespace MonoTests.System.IO
17 {
18         [TestFixture]
19         public class TextWriterTest : Assertion
20         {
21                 class MyTextWriter : TextWriter
22                 {
23                         public override Encoding Encoding { get { return Encoding.Default; } }
24
25                         internal MyTextWriter ()
26                                 : base (CultureInfo.InvariantCulture)
27                         {
28                         }
29
30                         public void UpdateLine ()
31                         {
32                                 CoreNewLine = new char [] {'Z'};
33                         }
34
35                         public void UpdateLine2 ()
36                         {
37                                 CoreNewLine [0] = 'Y';
38                         }
39                 }
40
41                 [Test]
42                 public void CoreNewLine ()
43                 {
44                         MyTextWriter w = new MyTextWriter ();
45                         AssertNotNull (w.NewLine);
46
47                         w.UpdateLine ();
48                         AssertEquals ('Z', w.NewLine [0]);
49
50                         w.UpdateLine2 ();
51                         AssertEquals ('Y', w.NewLine [0]);
52                 }
53
54                 class ArrayOrCharTester : TextWriter {
55                         public bool called_array;
56                         public override Encoding Encoding { get { return Encoding.UTF8; }}
57
58                         public override void Write (char [] x, int a, int b)
59                         {
60                                 called_array = true;
61                         }
62                         public override void Write (char c)
63                         {
64                         }
65                 }
66
67                 [Test]
68                 public void TestCharArrayCallsArrayIntInt ()
69                 {
70                         ArrayOrCharTester x = new ArrayOrCharTester ();
71                         x.Write (new char [] {'a','b','c'});
72                         AssertEquals (true, x.called_array);                    
73                 }
74         }
75 }