|
1 | 1 | package com.microsoft.graph.serializer; |
2 | 2 |
|
3 | 3 | import android.test.AndroidTestCase; |
4 | | -import junit.framework.Assert; |
| 4 | + |
5 | 5 | import java.util.Calendar; |
6 | 6 | import java.util.Date; |
7 | 7 | import java.util.TimeZone; |
8 | 8 |
|
9 | | - |
10 | 9 | /** |
11 | | - * Test cases for {@see CalendarSerializer} |
| 10 | + * Test cases for the {@see ISO8601} class |
12 | 11 | */ |
13 | | -public class CalendarSerializerTests extends AndroidTestCase { |
| 12 | +public class ISO8601Test extends AndroidTestCase { |
14 | 13 |
|
15 | | - public void testCalendarSerialize() throws Exception { |
| 14 | + /** |
| 15 | + * Make sure that dates with and without millis can be converted properly into strings |
| 16 | + * @throws Exception If there is an exception during the test |
| 17 | + */ |
| 18 | + public void testFromDate() throws Exception { |
16 | 19 | TimeZone.setDefault(TimeZone.getTimeZone("PST")); |
17 | 20 | final Calendar date = Calendar.getInstance(); |
18 | 21 | date.setTime(new Date(123456789012345L)); |
19 | | - Assert.assertEquals("5882-03-11T00:30:12.345Z", CalendarSerializer.serialize(date)); |
| 22 | + assertEquals("5882-03-11T00:30:12.345Z", CalendarSerializer.serialize(date)); |
20 | 23 |
|
21 | 24 | final Calendar dateNoMillis = Calendar.getInstance(); |
22 | 25 | dateNoMillis.setTime(new Date(123456789012000L)); |
23 | | - Assert.assertEquals("5882-03-11T00:30:12.000Z", CalendarSerializer.serialize(dateNoMillis)); |
| 26 | + assertEquals("5882-03-11T00:30:12.000Z", CalendarSerializer.serialize(dateNoMillis)); |
24 | 27 | } |
25 | 28 |
|
26 | | - public void testCalendarDeserialize() throws Exception { |
| 29 | + /** |
| 30 | + * Make sure that dates in string format with and without millis can be converted properly into date objects |
| 31 | + * @throws Exception If there is an exception during the test |
| 32 | + */ |
| 33 | + public void testToDate() throws Exception { |
27 | 34 | TimeZone.setDefault(TimeZone.getTimeZone("PST")); |
28 | 35 | final long toTheSecondDate = 123456789012000L; |
29 | 36 | final Calendar dateToSecond = CalendarSerializer.deserialize("5882-03-11T00:30:12Z"); |
30 | | - Assert.assertEquals(toTheSecondDate, dateToSecond.getTimeInMillis()); |
| 37 | + assertEquals(toTheSecondDate, dateToSecond.getTimeInMillis()); |
31 | 38 |
|
32 | 39 | final long toTheMillisecondDate = 123456789012345L; |
33 | 40 | final Calendar dateToTheMillisecond = CalendarSerializer.deserialize("5882-03-11T00:30:12.345Z"); |
34 | | - Assert.assertEquals(toTheMillisecondDate, dateToTheMillisecond.getTimeInMillis()); |
| 41 | + assertEquals(toTheMillisecondDate, dateToTheMillisecond.getTimeInMillis()); |
35 | 42 |
|
36 | 43 | final Calendar dateToTheExtremeMillisecond = CalendarSerializer.deserialize("5882-03-11T00:30:12.3456789Z"); |
37 | | - Assert.assertEquals(toTheMillisecondDate, dateToTheExtremeMillisecond.getTimeInMillis()); |
| 44 | + assertEquals(toTheMillisecondDate, dateToTheExtremeMillisecond.getTimeInMillis()); |
38 | 45 | } |
| 46 | + |
39 | 47 | } |
0 commit comments