remove TARGET_JVM
[mono.git] / mcs / class / corlib / Test / System.Globalization / DaylightTimeTest.cs
1 //
2 // BinaryFormatterTest.cs - Unit tests for 
3 //      System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
4 //
5 // Author:
6 //      Sebastien Pouliot  <sebastien@ximian.com>
7 //
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 using System;
31 using System.IO;
32 using System.Globalization;
33 using System.Runtime.Serialization.Formatters.Binary;
34
35 using NUnit.Framework;
36
37 namespace MonoTests.System.Globalization {
38
39         [TestFixture]
40         public class DaylightTimeTest {
41
42                 [Test]
43                 public void Constructor ()
44                 {
45                         DaylightTime dt = new DaylightTime (DateTime.MinValue, DateTime.MaxValue, TimeSpan.MinValue);
46                         Assert.AreEqual (DateTime.MinValue, dt.Start, "Start");
47                         Assert.AreEqual (DateTime.MaxValue, dt.End, "End");
48                         Assert.AreEqual (TimeSpan.MinValue, dt.Delta, "Delta");
49                 }
50
51                 [Test]
52                 public void SerializationRoundtrip ()
53                 {
54                         DaylightTime dt = new DaylightTime (DateTime.MinValue, DateTime.MaxValue, TimeSpan.MinValue);
55                         BinaryFormatter bf = new BinaryFormatter ();
56                         MemoryStream ms = new MemoryStream ();
57                         bf.Serialize (ms, dt);
58
59                         ms.Position = 0;
60                         DaylightTime clone = (DaylightTime) bf.Deserialize (ms);
61
62                         Assert.AreEqual (clone.Start, dt.Start, "Start");
63                         Assert.AreEqual (clone.End, dt.End, "End");
64                         Assert.AreEqual (clone.Delta, dt.Delta, "Delta");
65                 }
66
67                 static private byte[] serialized_daylighttime = {
68                         0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
69                         0x04, 0x01, 0x00, 0x00, 0x00, 0x21, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x47, 0x6C, 0x6F, 0x62, 
70                         0x61, 0x6C, 0x69, 0x7A, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2E, 0x44, 0x61, 0x79, 0x6C, 0x69, 0x67, 0x68, 
71                         0x74, 0x54, 0x69, 0x6D, 0x65, 0x03, 0x00, 0x00, 0x00, 0x07, 0x6D, 0x5F, 0x73, 0x74, 0x61, 0x72, 0x74, 
72                         0x05, 0x6D, 0x5F, 0x65, 0x6E, 0x64, 0x07, 0x6D, 0x5F, 0x64, 0x65, 0x6C, 0x74, 0x61, 0x00, 0x00, 0x00, 
73                         0x0D, 0x0D, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x3F, 0x37, 0xF4, 0x75, 0x28, 
74                         0xCA, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0B
75                 };
76
77                 [Test]
78                 public void DeserializeKnownValue ()
79                 {
80                         MemoryStream ms = new MemoryStream (serialized_daylighttime);
81                         BinaryFormatter bf = new BinaryFormatter ();
82                         DaylightTime dt = (DaylightTime) bf.Deserialize (ms);
83                         Assert.AreEqual (DateTime.MinValue, dt.Start, "Start");
84                         Assert.AreEqual (DateTime.MaxValue, dt.End, "End");
85                         Assert.AreEqual (TimeSpan.MinValue, dt.Delta, "Delta");
86                 }
87         }
88 }