2007-10-19 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System / Test / System.Net.Mail / AlternateViewTest.cs
1 //
2 // AlternateViewTest.cs - NUnit Test Cases for System.Net.MailAddress.AlternateView
3 //
4 // Authors:
5 //   John Luke (john.luke@gmail.com)
6 //
7 // (C) 2005 John Luke
8 //
9 #if NET_2_0
10 using NUnit.Framework;
11 using System;
12 using System.IO;
13 using System.Net.Mail;
14 using System.Net.Mime;
15
16 namespace MonoTests.System.Net.Mail
17 {
18         [TestFixture]
19         public class AlternateViewTest
20         {
21                 AlternateView av;
22                 
23                 [SetUp]
24                 public void GetReady ()
25                 {
26                         av = AlternateView.CreateAlternateViewFromString ("test", new ContentType ("text/plain"));
27                 }
28
29                 [Test]
30                 [ExpectedException (typeof (ArgumentNullException))]
31                 public void ArgumentNullException ()
32                 {
33                         string s = null;
34                         new AlternateView (s);
35                 }
36
37                 [Test]
38                 [ExpectedException (typeof (ArgumentNullException))]
39                 public void ArgumentNullException2 ()
40                 {
41                         Stream s = null;
42                         new AlternateView (s);
43                 }
44
45                 [Test]
46                 public void ContentType ()
47                 {
48                         Assert.IsNotNull (av.ContentType);
49                         Assert.IsTrue (av.ContentType.MediaType == "text/plain");
50                 }
51
52                 [Test]
53                 public void ContentType2 ()
54                 {
55                         AlternateView av = new AlternateView (new MemoryStream ());
56                         Assert.IsNotNull (av.ContentType, "#1");
57                         Assert.AreEqual ("application/octet-stream", av.ContentType.MediaType, "#2");
58                 }
59
60                 [Test]
61                 public void ContentStream ()
62                 {
63                         Assert.IsNotNull (av.ContentStream);
64                         Assert.IsTrue (av.ContentStream.Length == 4);
65                 }
66
67                 [Test]
68                 public void TransferEncodingTest ()
69                 {
70                         Assert.AreEqual (TransferEncoding.QuotedPrintable, av.TransferEncoding, "#1");
71
72                         MemoryStream ms = new MemoryStream (new byte [] {1, 2, 3});
73                         Assert.AreEqual (TransferEncoding.Base64, new AlternateView (ms).TransferEncoding, "#2");
74                         Assert.AreEqual (TransferEncoding.Base64, new AlternateView (ms, "text/plain").TransferEncoding, "#3");
75                 }
76         }
77 }
78 #endif