package cn.sunner.sms2calendar;

import org.junit.Test;

import java.util.Calendar;
import java.util.GregorianCalendar;

import static org.junit.Assert.assertEquals;

/**
 * Created by Sunner on 7/16/16.
 */
public class N12306ParserTest {

    @Test
    public void testOneSeat() throws Exception {
        SMSParser parser = new N12306Parser("订单EC11541789,孙先生您已购1月24日D2245次14车13F号南京南19:11开。【铁路客服】");
        assertEquals("D2245次14车13F号", parser.getTitle());
        assertEquals("南京南", parser.getLocation());
        assertEquals(new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), 1, 24, 19, 11), parser.getBeginTime());
    }

    @Test
    public void testTwoSeatsAndChanged() throws Exception {
        SMSParser parser = new N12306Parser("订单EC71177015,孙先生您已签12月9日D2245次14车12D号、4C号上海虹桥19:11开。【铁路客服】");
        assertEquals("D2245次14车12D号、4C号", parser.getTitle());
        assertEquals("上海虹桥", parser.getLocation());
        assertEquals(new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), 12, 9, 19, 11), parser.getBeginTime());
    }

    @Test
    public void testTwoBeds() throws Exception {
        SMSParser parser = new N12306Parser("订单EC76805753,孙先生您已购2月1日Z176次12车31号下铺、36号上铺杭州9:30开。【铁路客服】");
        assertEquals("Z176次12车31号下铺、36号上铺", parser.getTitle());
        assertEquals("杭州", parser.getLocation());
        assertEquals(new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), 2, 1, 9, 30), parser.getBeginTime());
    }

}
@@ -145,28 +145,17 @@
 .Assert.
-assertEquals
+*
 ;%0A%0A/**%0A 
@@ -376,32 +376,70 @@
 9:11%E5%BC%80%E3%80%82%E3%80%90%E9%93%81%E8%B7%AF%E5%AE%A2%E6%9C%8D%E3%80%91%22);%0A
+        assertTrue(parser.isValid());%0A
         assertEq
@@ -833,32 +833,70 @@
 9:11%E5%BC%80%E3%80%82%E3%80%90%E9%93%81%E8%B7%AF%E5%AE%A2%E6%9C%8D%E3%80%91%22);%0A
+        assertTrue(parser.isValid());%0A
         assertEq
@@ -1282,32 +1282,70 @@
 9:30%E5%BC%80%E3%80%82%E3%80%90%E9%93%81%E8%B7%AF%E5%AE%A2%E6%9C%8D%E3%80%91%22);%0A
+        assertTrue(parser.isValid());%0A
         assertEq
@@ -1434,32 +1434,32 @@
 getLocation());%0A
-
         assertEq
@@ -1573,9 +1573,227 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testNotValid() throws Exception %7B%0A        SMSParser parser = new N12306Parser(%22%E5%AD%99%E5%BF%97%E5%B2%97%E7%9A%842%E6%9C%884%E6%97%A5G7394%E6%AC%A18%E8%BD%A615B%E5%8F%B7%E8%BD%A6%E7%A5%A8%E9%80%80%E7%A5%A8%E6%88%90%E5%8A%9F%E3%80%82%E6%B5%81%E6%B0%B4%E5%8F%B72EC84941031001001222209833%E3%80%82%E3%80%90%E9%93%81%E8%B7%AF%E5%AE%A2%E6%9C%8D%E3%80%91%22);%0A        assertFalse(parser.isValid());%0A    %7D%0A%0A
 %7D

Add isValid() testcase