public void CanDeserializeSampleADX() { var adxData = GetResource("sample.adx"); var data = ADIFIO.ConvertFromADX(adxData); Assert.IsTrue(data.Header.ADIFVersion == "3.0.4"); Assert.IsTrue(data.Header.ProgramID == "monolog"); Assert.IsTrue(data.Header.UserDefinedFields.Count == 3); Assert.IsTrue(data.Header.UserDefinedFields.Any(f => f.FieldID == 1 && f.Type == "N" && f.Value == "EPC")); Assert.IsTrue(data.Records.Count == 2); Assert.IsTrue(data.Records.Any(r => r.QSODate == "19900620" && r.TimeOn == "1523" && r.Callsign == "VK9NS" && r.Band == "20M" && r.Mode == "RTTY" && r.UserDefinedFields.Count == 2 && r.UserDefinedFields.Any(u => u.FieldName == "SWEATERSIZE" && u.Value == "M") && r.AppDefinedFields.Count == 1 && r.AppDefinedFields.Any(a => a.ProgramID == "MONOLOG" && a.FieldName == "Compression" && a.DataType == "s" && a.Data == "off"))); }
public void CanSerializeSampleFile() { // serialize sample ADX file from http://www.adif.org/304/ADIF_304.htm#ADX_File_Format var dataObject = new ADIFData(); dataObject.Header = new ADIFHeader(); dataObject.Header.ADIFVersion = ADIFIO.ADIFVersion; dataObject.Header.ProgramID = "monolog"; dataObject.Header.UserDefinedFields = new List <ADIFUserDefinedFieldHeader>(); dataObject.Header.UserDefinedFields.Add(new ADIFUserDefinedFieldHeader { FieldID = 1, Type = "N", Value = "EPC" }); dataObject.Header.UserDefinedFields.Add(new ADIFUserDefinedFieldHeader { FieldID = 2, Type = "E", Enum = "{S,M,L}", Value = "SWEATERSIZE" }); dataObject.Header.UserDefinedFields.Add(new ADIFUserDefinedFieldHeader { FieldID = 3, Type = "E", Range = "{5:20}", Value = "SHOESIZE" }); dataObject.Records = new List <ADIFRecord>(); var firstRecord = new ADIFRecord(); firstRecord.QSODate = "19900620"; firstRecord.TimeOn = "1523"; firstRecord.Callsign = "VK9NS"; firstRecord.Band = "20M"; firstRecord.Mode = "RTTY"; firstRecord.UserDefinedFields = new List <ADIFUserDefinedFieldRecord>(); firstRecord.UserDefinedFields.Add(new ADIFUserDefinedFieldRecord("SWEATERSIZE", "M")); firstRecord.UserDefinedFields.Add(new ADIFUserDefinedFieldRecord("SHOESIZE", "11")); firstRecord.AppDefinedFields = new List <ADIFAppDefinedFieldRecord>(); firstRecord.AppDefinedFields.Add(new ADIFAppDefinedFieldRecord("MONOLOG", "Compression", "s", "off")); var secondRecord = new ADIFRecord(); secondRecord.QSODate = "20101022"; secondRecord.TimeOn = "0111"; secondRecord.Callsign = "ON4UN"; secondRecord.Band = "40M"; secondRecord.Mode = "PSK"; secondRecord.Submode = "PSK63"; secondRecord.UserDefinedFields = new List <ADIFUserDefinedFieldRecord>(); secondRecord.UserDefinedFields.Add(new ADIFUserDefinedFieldRecord("EPC", "32123")); secondRecord.AppDefinedFields = new List <ADIFAppDefinedFieldRecord>(); secondRecord.AppDefinedFields.Add(new ADIFAppDefinedFieldRecord("MONOLOG", "COMPRESSION", "s", "off")); dataObject.Records.Add(firstRecord); dataObject.Records.Add(secondRecord); var adx = ADIFIO.ConvertToADX(dataObject); ADIFIO.SaveADXFile(dataObject, "C:\\data.xml"); }
public void CanSerializeHeaderAndNoRecords() { var dataObject = new ADIFData(); dataObject.Header = new ADIFHeader { ADIFVersion = ADIFIO.ADIFVersion, CreatedTimestamp = "20150118 234500", ProgramID = "Test Program", ProgramVersion = "0.1 alpha" }; dataObject.Records = new List <ADIFRecord>(); var adx = ADIFIO.ConvertToADX(dataObject); var rgx = new Regex(@"<\?xml.+\?>\s*<ADX>\s*<HEADER>[\s\S]*<\/HEADER>\s*<RECORDS \/>\s*<\/ADX>"); Assert.IsTrue(rgx.IsMatch(adx)); }