public void CodeTest() { // SmsAwsPreParser parser = new SmsAwsPreParser(); var smsAwsParser = new SmsAwsParser(); const string s = "(S:JABALALKAWR;D:050914;T:170000;PR:0.6;TA:1.1)"; var results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 2); ValidateResults(results); var testTime = new DateTime(2005, 9, 14, 17, 0, 0); var msg = smsAwsParser.ParseMessageIntoMeasMsg(s); Assert.True(msg.Station == "JABALALKAWR"); var meas = new Meas(); Assert.True(msg.GetMeasByName("PR", ref meas)); //Assert.True(((Meas)(msg.MeasList[0])).ObsTime == testTime); Assert.True(meas.ObsTime == testTime); Assert.True(msg.Count == 2); // Test starts here var tmp = SmsAwsParser.Code(msg); Assert.True(tmp.Length > 0); results = smsAwsParser.ParseMessage(tmp); Assert.True(results.Count == 2); ValidateResults(results); } // ParserTest1
public void DisdroSmsAwsMsg() { // SmsAwsPreParser parser = new SmsAwsPreParser(); var smsAwsParser = new SmsAwsParser(); var sb = new StringBuilder(); var s = string.Empty; var results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 0); sb.Append(" DCP_MSG repþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ L ø Qô ‡! ¼N ñ{ý ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ | æ P º $ ŽûOWZ1 î L Z(S:Station3;D:120307;T:125300;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)"); sb.Append(@"ûOWZm [ Z(S:Station3;D:120307;T:125400;PR1H:7;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)"); sb.Append(@"ûOWZ© È î Z(S:Station3;D:120307;T:125500;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)"); sb.Append(@"ûOWZå 5 [ Z(S:Station3;D:120307;T:125600;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)"); sb.Append(@"ûOW[ ¢ È Z(S:Station3;D:120307;T:125700;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)"); sb.Append(@"ûOW[\ 5 Z(S:Station3;D:120307;T:125800;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)"); sb.Append(@"ûOW[™ | ¢ Z(S:Station3;D:120307;T:125900;PR1H:/;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)"); sb.Append(@"ûOW[Ô í ^(S:Station3;D:120307;T:130000;PR1H:0.000;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)"); sb.Append(@"ûOW\ ^ | ^(S:Station3;D:120307;T:130100;PR1H:0.000;LAT:60.000000;LON:25.000000;QUAL:/;R1MIN:/;Z1MIN:/)"); s = sb.ToString(); results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 70); var testTime = new DateTime(2012, 3, 7, 12, 54, 0); var multiMeasMsg = smsAwsParser.ParseMessageIntoMultipleMeasMsg(s); foreach (var msg in multiMeasMsg.MeasMsgList) { Assert.True(msg.Station == "Station3"); var meas = new Meas(); Assert.True(msg.GetMeasByName("PR1H", ref meas)); //Assert.True(((Meas)(msg.MeasList[0])).ObsTime == testTime); // Assert.True(meas.ObsTime == testTime); if (meas.ObsTime == testTime) { Assert.True(meas.ObsValue == "7"); Assert.True(msg.Count == 6); } } } // ParserTest1
public void SmsAwsParserTest() { // SmsAwsPreParser parser = new SmsAwsPreParser(); var smsAwsParser = new SmsAwsParser(); Assert.True(smsAwsParser.indexOfFirstValue == 3); var s = string.Empty; var results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 0); s = "(PR:0.6;TA:1.1)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 0); s = "(S:;D:050914;T:170000;PR:0.6;TA:1.1)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 0); s = "(S:JABALALKAWR;T:170000;PR:0.6;TA:1.1)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 0); s = "(S:JABALALKAWR;D:050914;250000;PR:0.6;TA:1.1)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 0); s = "(S:JABALALKAWR;D:050914;T:170000;PR:0.6;TA:1.1)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 2); s = "(S:JABALALKAWR;D:050914;T:170000;PR:0.6;TA:1.1;)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 2); s = "(S:JABALALKAWR;D:050914;T:170000;PR:0.6;TIMEOFWS:12:00:00;)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 2); ValidateResults(results); var testTime = new DateTime(2005, 9, 14, 17, 0, 0); var msg = smsAwsParser.ParseMessageIntoMeasMsg(s); Assert.True(msg.Station == "JABALALKAWR"); var meas = new Meas(); Assert.True(msg.GetMeasByName("PR", ref meas)); //Assert.True(((Meas)(msg.MeasList[0])).ObsTime == testTime); Assert.True(meas.ObsTime == testTime); Assert.True(msg.Count == 2); } // ParserTest1
public void SmsAwsParserTestWithNoStationOrDateTime() { // SmsAwsPreParser parser = new SmsAwsPreParser(); var smsAwsParser = new SmsAwsParser() { indexOfFirstValue = 0 }; Assert.True(smsAwsParser.indexOfFirstValue == 0); var s = string.Empty; var results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 0); s = "(PR:0.6;TA:1.1)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 2); s = "(S:;D:140901;T:170000;PR:0.6;TA:1.1)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 5); s = "(S:JABALALKAWR;T:170000;PR:0.6;TA:1.1)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 4); s = "(S:JABALALKAWR;D:140901;250000;PR:0.6;TA:1.1)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 2); s = "(S:JABALALKAWR;D:140901;T:170000;PR:0.6;TA:1.1)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 5); s = "(S:JABALALKAWR;D:140901;T:170000;PR:0.6;TA:1.1;)"; results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 5); ValidateResults(results); var msg = smsAwsParser.ParseMessageIntoMeasMsg(s); Assert.True(msg.Station == "S1"); var meas = new Meas(); Assert.True(msg.GetMeasByName("PR", ref meas)); //Assert.True(((Meas)(msg.MeasList[0])).ObsTime == testTime); TimeSpan diff = meas.ObsTime.Subtract(DateTime.Now); Assert.True(diff.TotalSeconds < 2); Assert.True(msg.Count == 5); } // ParserTest1
public void CodePansioTest() { // SmsAwsPreParser parser = new SmsAwsPreParser(); var smsAwsParser = new SmsAwsParser(); const string s = "(S:PANSIO;D:130109;T:095126;QFEAVG1M:1030.1;TAAVG1M:13.1;TWAVG1M:12.1; VIS:1234;WLAVG1M:57;WD:34;WS:5.1)"; var results = smsAwsParser.ParseMessage(s); Assert.True(results.Count == 7); ValidateResults(results); var msg = smsAwsParser.ParseMessageIntoMeasMsg(s); Assert.True(msg.Station == "PANSIO"); // Test starts here var tmp = SmsAwsParser.Code(msg); Assert.True(tmp.Length > 0); results = smsAwsParser.ParseMessage(tmp); Assert.True(results.Count == 7); ValidateResults(results); } // ParserTest1