public void TestModifyValues2VCreditsGranted() { string err = string.Empty; string modStr = string.Empty; Qso2 qso = new Qso2("<Credit_Granted:14>DXCC:CARD&LOTW<Eqsl_Qsl_Rcvd:1>V", aEnums, ref err); Assert.IsNull(err); Eqsl_Qsl_Rcvd rcvd = qso.GetField("Eqsl_Qsl_Rcvd") as Eqsl_Qsl_Rcvd; Assert.IsNotNull(rcvd); modStr = rcvd.ModifyValues2(qso); rcvd = qso.GetField("Eqsl_Qsl_Rcvd") as Eqsl_Qsl_Rcvd; Assert.IsNull(rcvd); Assert.AreEqual("\tValue 'V' is deprecated and replaced with Credit_Granted values: " + "'DXCC:EQSL', 'DXCC_BAND:EQSL', and 'DXCC_MODE:EQSL'." + Environment.NewLine, modStr); Credit_Granted granted = qso.GetField("Credit_Granted") as Credit_Granted; Assert.IsNotNull(granted); List<Credit> credits = granted.GetCredits("DXCC"); Assert.AreEqual(1, credits.Count); Assert.AreEqual("DXCC:CARD&LOTW&EQSL", credits[0].ToString()); Assert.IsTrue(credits[0].IsInMedia("EQSL")); credits = granted.GetCredits("DXCC_BAND"); Assert.IsTrue(credits[0].IsInMedia("EQSL")); credits = granted.GetCredits("DXCC_Mode"); Assert.IsTrue(credits[0].IsInMedia("eqsl")); }
public void TestModifyValuesWithOperatorField() { string err = string.Empty; Qso2 qso = new Qso2("<Guest_Op:5>VA3HJ<Operator:6>VA3JNO", aEnums, ref err); Guest_Op guest = qso.GetField("Guest_Op") as Guest_Op; string mod = guest.ModifyValues(qso); guest = qso.GetField("Guest_Op") as Guest_Op; Assert.IsNull(guest); Assert.AreEqual("\tGuest_Op field cannot be changed to Operator field because Operator field already exists. Guest_Op field deleted." + Environment.NewLine, mod); }
public void TestModifyValuesNull() { string err = string.Empty; Qso2 qso = new Qso2("<Lotw_QslSDate:8>20120916", aEnums, ref err); Lotw_QslSDate date = qso.GetField("Lotw_QslSDate") as Lotw_QslSDate; Assert.IsNotNull(date); err = date.ModifyValues(qso); date = qso.GetField("Lotw_QslSDate") as Lotw_QslSDate; Assert.IsNull(date); Assert.AreEqual("\tLotw_QslSDate field deleted. This field is only valid when Lotw_Qsl_Sent field is Y, Q, or I." + Environment.NewLine, err); }
public void TestModifyValuesNull() { string err = string.Empty; Qso2 qso = new Qso2("<Eqsl_QslRDate:8>20120916", aEnums, ref err); Eqsl_QslRDate date = qso.GetField("Eqsl_QslRDate") as Eqsl_QslRDate; Assert.IsNotNull(date); err = date.ModifyValues(qso); date = qso.GetField("Eqsl_QslRDate") as Eqsl_QslRDate; Assert.IsNull(date); Assert.AreEqual("\tEqsl_QslRDate field deleted. This field is only valid when Eqsl_Qsl_Rcvd field is Y, I, or V." + Environment.NewLine, err); }
public void TestModifyValuesMStatus() { string err = string.Empty; string modStr = string.Empty; Qso2 qso = new Qso2("<Qsl_Rcvd_Via:1>M", aEnums, ref err); Qsl_Rcvd_Via status = qso.GetField("Qsl_Rcvd_Via") as Qsl_Rcvd_Via; Assert.IsNotNull(status); string mod = status.ModifyValues(qso); Assert.AreEqual("\tQsl_Rcvd_Via value 'M' deprecated with no replacement value. Field deleted." + Environment.NewLine, mod); status = qso.GetField("Qsl_Rcvd_Via") as Qsl_Rcvd_Via; Assert.IsNull(status); }
public void TestModifyValuesEStatus() { string err = string.Empty; string modStr = string.Empty; Qso2 qso = new Qso2("<Qsl_Rcvd_Via:1>E", aEnums, ref err); Qsl_Rcvd_Via status = qso.GetField("Qsl_Rcvd_Via") as Qsl_Rcvd_Via; Assert.IsNotNull(status); string mod = status.ModifyValues(qso); Assert.IsNull(mod); status = qso.GetField("Qsl_Rcvd_Via") as Qsl_Rcvd_Via; Assert.IsNotNull(status); Assert.AreEqual("E", status.Value); }
public void TestModifyValuesWithOwnerCallsign() { string err = string.Empty; Qso2 qso = new Qso2("<Station_Callsign:5>VA3HJ<Owner_Callsign:6>VA3JNO", aEnums, ref err); Station_Callsign call = qso.GetField("Station_Callsign") as Station_Callsign; Assert.IsNotNull(call); string mod = call.ModifyValues(qso); Owner_Callsign owner = qso.GetField("Owner_Callsign") as Owner_Callsign; Assert.IsNotNull(owner); Assert.AreNotEqual(call.Value, owner.Value); Assert.AreEqual("VA3JNO", owner.Value); Assert.IsNull(mod); }
public void TestModifyValuesNoState() { string err = string.Empty; Qso2 qso = new Qso2("<VE_PROV:2>ON", aEnums, ref err); VE_Prov prov = qso.GetField("VE_Prov") as VE_Prov; Assert.IsNotNull(prov); string mod = prov.ModifyValues(qso); prov = qso.GetField("VE_Prov") as VE_Prov; Assert.IsNull(prov); State state = qso.GetField("State") as State; Assert.AreEqual("ON", state.Value); Assert.AreEqual("\tVE_Prov field deprecated. VE_Prov field deleted and replaced with State field." + Environment.NewLine, mod); }
public void TestModifyValuesStation_Callsign() { string err = string.Empty; Qso2 qso = new Qso2("<Operator:5>VA3HJ<Station_Callsign:6>VA3JNO", aEnums, ref err); Operator op = qso.GetField("Operator") as Operator; Assert.IsNotNull(op); err = op.ModifyValues(qso); op = qso.GetField("Operator") as Operator; Assert.IsNotNull(op); Assert.IsNull(err); Station_Callsign call = qso.GetField("Station_Callsign") as Station_Callsign; Assert.IsNotNull(call); Assert.AreEqual("VA3JNO", call.Value); }
public void TestModifyValuesState() { string err = string.Empty; Qso2 qso = new Qso2("<VE_PROV:2>ON<STATE:2>AB", aEnums, ref err); VE_Prov prov = qso.GetField("VE_Prov") as VE_Prov; Assert.IsNotNull(prov); string mod = prov.ModifyValues(qso); prov = qso.GetField("VE_Prov") as VE_Prov; Assert.IsNull(prov); State state = qso.GetField("State") as State; Assert.AreEqual("AB", state.Value); Assert.AreEqual("\tVE_Prov field deprecated. State field already exists, so VE_Prov field deleted." + Environment.NewLine, mod); }
public void TestModifyValuesFalse( [Values("N", "R")] string rcvd) { string adif = string.Format("<Lotw_Qsl_Rcvd:1>{0}<Lotw_QslRDate:8>20120916", rcvd); string err = string.Empty; Qso2 qso = new Qso2(adif, aEnums, ref err); Lotw_QslRDate date = qso.GetField("Lotw_QslRDate") as Lotw_QslRDate; Assert.IsNotNull(date); err = date.ModifyValues(qso); date = qso.GetField("Lotw_QslRDate") as Lotw_QslRDate; Assert.IsNull(date); Assert.AreEqual("\tLotw_QslRDate field deleted. This field is only valid when Lotw_Qsl_Rcvd field is Y, I, or V." + Environment.NewLine, err); }
public void TestModifyValuesFalse( [Values("N", "R")] string sent) { string adif = string.Format("<Qsl_Sent:1>{0}<QslSDate:8>20120916", sent); string err = string.Empty; Qso2 qso = new Qso2(adif, aEnums, ref err); QslSDate date = qso.GetField("QslSDate") as QslSDate; Assert.IsNotNull(date); err = date.ModifyValues(qso); date = qso.GetField("QslSDate") as QslSDate; Assert.IsNull(date); Assert.AreEqual("\tQslSDate field deleted. This field is only valid when Qsl_Sent field is Y, Q, or I." + Environment.NewLine, err); }
public void TestModifyValuesNoOwnerCallsign() { string err = string.Empty; Qso2 qso = new Qso2("", aEnums, ref err); Station_Callsign call = new Station_Callsign("VA3HJ"); qso.Fields.Add(call); Owner_Callsign owner = qso.GetField("Owner_Callsign") as Owner_Callsign; Assert.IsNull(owner); string mod = call.ModifyValues(qso); owner = qso.GetField("Owner_Callsign") as Owner_Callsign; Assert.IsNotNull(owner); Assert.AreEqual(call.Value, owner.Value); Assert.AreEqual("\tOwner_Callsign field generated from Station_Callsign" + Environment.NewLine, mod); }
public void TestModifyValuesNoStation_Callsign() { string err = string.Empty; Qso2 qso = new Qso2("<Operator:5>VA3HJ", aEnums, ref err); Operator op = qso.GetField("Operator") as Operator; Assert.IsNotNull(op); err = op.ModifyValues(qso); op = qso.GetField("Operator") as Operator; Assert.IsNotNull(op); Assert.AreEqual("\tStation_Callsign field generated from Operator field." + Environment.NewLine, err); Station_Callsign call = qso.GetField("Station_Callsign") as Station_Callsign; Assert.IsNotNull(call); Assert.AreEqual("VA3HJ", call.Value); }
public void TestModifyValuesWithInalidModeWithValidSubmode() { string err = string.Empty; Qso2 qso = new Qso2("<Mode:6>SQUIBB<Submode:3>LSB", aEnums, ref err); AdifField field = qso.GetField("Mode"); Assert.IsNotNull(field); Mode mode = field as Mode; Assert.IsNotNull(mode); Assert.AreEqual("\tMode not found in Mode enumeration. Mode set to mode for submode.", mode.ModifyValues(qso)); Assert.AreEqual("SSB", mode.Value); Submode submode = qso.GetField("Submode") as Submode; Assert.IsNotNull(submode); Assert.AreEqual("LSB", submode.Value); }
/// <summary> /// Change deprecated values to their replacements /// /// </summary> /// <param name="qso">Qso2 object containing this field</param> /// <returns>string containing message about changes made</returns> public override string ModifyValues2(Qso2 qso) { // this code must be in ModifyValues2, not ModifyValues, because this code changes // status of 'V' which must be present when Eqsl_QslRDate.ModifyValues is called. // We cannot guarantee the order in which objects in Qso2.Fields is stored. string mod = string.Empty; string modStr = null; if(Value.Equals("V")) { Credit_Granted granted = qso.GetField("Credit_Granted") as Credit_Granted; if(granted == null) { Credit_Granted credGranted = new Credit_Granted("DXCC:CARD,DXCC_BAND:CARD,DXCC_Mode:CARD", aEnums); qso.Fields.Add(credGranted); } else { granted.Add(new Credit("DXCC:CARD", aEnums)); granted.Add(new Credit("DXCC_BAND:CARD", aEnums)); granted.Add(new Credit("DXCC_MODE:CARD", aEnums)); } qso.Fields.Remove(this); modStr = "\tValue 'V' is deprecated and replaced with Credit_Granted values: 'DXCC:CARD', 'DXCC_BAND:CARD', and 'DXCC_MODE:CARD'." + Environment.NewLine; } return modStr; }
public void TestModifyValuesValidCall() { string err = string.Empty; Qso2 qso = new Qso2("<Guest_Op:5>VA3HJ", aEnums, ref err); Guest_Op guest = qso.GetField("Guest_Op") as Guest_Op; string mod = guest.ModifyValues(qso); guest = qso.GetField("Guest_Op") as Guest_Op; Assert.IsNull(guest); Operator op = qso.GetField("Operator") as Operator; Assert.IsNotNull(op); Station_Callsign call = qso.GetField("Station_Callsign") as Station_Callsign; Assert.IsNotNull(call); Assert.AreEqual(op.Value, call.Value); Assert.AreEqual("\tGuest_Op field changed to Operator field." + Environment.NewLine + "\tStation_Callsign field generated from Operator field." + Environment.NewLine, mod); }
public void TestModifyValuesWithMatchingValues() { string err = string.Empty; Qso2 qso = new Qso2("<Freq_Rx:6>14.263<Band_Rx:3>20m", aEnums, ref err); Assert.IsNull(err); AdifField field = qso.GetField("Freq_Rx"); Assert.IsNotNull(field); Freq_Rx freq = field as Freq_Rx; Assert.IsNotNull(freq); Assert.IsNull(freq.ModifyValues(qso)); }
public void TestModifyNWT() { string err = string.Empty; Qso2 qso = new Qso2("<arrl_sect:3>NWT", aEnums, ref err); Arrl_Sect nwt = qso.GetField("Arrl_Sect") as Arrl_Sect; Assert.IsNotNull(nwt); string mod = nwt.ModifyValues(qso); Assert.AreEqual("NT", nwt.Value); Assert.AreEqual("\tArrl_Sect:" + Environment.NewLine + "\t\tDeprecated section 'NWT' changed to 'NT'." + Environment.NewLine, mod); }
public void TestModifyValuesWithMisMatchedValues() { string err = string.Empty; Qso2 qso = new Qso2("<Freq:6>14.263<Band:3>10m", aEnums, ref err); Assert.IsNull(err); AdifField field = qso.GetField("Freq"); Assert.IsNotNull(field); Freq freq = field as Freq; Assert.IsNotNull(freq); Assert.AreEqual("\tHam band in Band field does not match band for given frequency." + " Band field modified to match the frequency.", freq.ModifyValues(qso)); }
public void TestModifyValues2V() { string err = string.Empty; string modStr = string.Empty; Qso2 qso = new Qso2("<Qsl_Rcvd:1>V", aEnums,ref err); Qsl_Rcvd rcvd = qso.GetField("Qsl_Rcvd") as Qsl_Rcvd; Assert.IsNotNull(rcvd); modStr = rcvd.ModifyValues2(qso); rcvd = qso.GetField("Qsl_Rcvd") as Qsl_Rcvd; Assert.IsNull(rcvd); Assert.AreEqual("\tValue 'V' is deprecated and replaced with Credit_Granted values: " + "'DXCC:CARD', 'DXCC_BAND:CARD', and 'DXCC_MODE:CARD'." + Environment.NewLine, modStr); Credit_Granted granted = qso.GetField("Credit_Granted") as Credit_Granted; Assert.IsNotNull(granted); List<Credit> credits = granted.GetCredits("DXCC"); Assert.IsTrue(credits[0].IsInMedia("CARD")); credits = granted.GetCredits("DXCC_BAND"); Assert.IsTrue(credits[0].IsInMedia("CARD")); credits = granted.GetCredits("DXCC_Mode"); Assert.IsTrue(credits[0].IsInMedia("card")); }
public void TestModifyValuesEa_Rtty() { string err = string.Empty; string modStr = string.Empty; Qso2 qso = new Qso2("<contest_ID:7>EA-RTTY", aEnums, ref err); Contest_Id id = qso.GetField("Contest_Id") as Contest_Id; Assert.IsNotNull(id); modStr = id.ModifyValues(qso); Assert.AreEqual("EA-WW-RTTY", id.Value); Assert.AreEqual("\tContest_Id:" + Environment.NewLine + "\t\tDeprecated value 'EA-RTTY' changed to 'EA-WW-RTTY'." + Environment.NewLine, modStr); }
/// <summary> /// This field is valid only if Eqsl_Qsl_Sent is Y, Q, or I. /// Delete field if other value or null /// </summary> /// <param name="qso">Qso2 object containing this field</param> /// <returns>string containing modification message</returns> public override string ModifyValues(Qso2 qso) { string mod = null; Eqsl_Qsl_Sent sent = qso.GetField("Eqsl_Qsl_Sent") as Eqsl_Qsl_Sent; if(sent == null || (sent.Value != "Y" && sent.Value != "Q" && sent.Value != "I")) { qso.Fields.Remove(this); mod = "\tEqsl_QslSDate field deleted. This field is only valid when " + "Eqsl_Qsl_Sent field is Y, Q, or I." + Environment.NewLine; } return mod; }
/// <summary> /// This field is valid only if Eqsl_Qsl_Rcvd is Y, I, or V. /// Delete field if other value or null /// </summary> /// <param name="qso">Qso2 object containing this field</param> /// <returns>string containing modification message</returns> public override string ModifyValues(Qso2 qso) { string mod = null; Eqsl_Qsl_Rcvd rcvd = qso.GetField("Eqsl_Qsl_Rcvd") as Eqsl_Qsl_Rcvd; if(rcvd == null || (rcvd.Value != "Y" && rcvd.Value != "I" && rcvd.Value != "V")) { qso.Fields.Remove(this); mod = "\tEqsl_QslRDate field deleted. This field is only valid when " + "Eqsl_Qsl_Rcvd field is Y, I, or V." + Environment.NewLine; } return mod; }
/// <summary> /// Generate Station_Callsign field from this field, if does not exist /// </summary> /// <param name="qso">Qso2 object containing this field</param> /// <returns>string describing the modification made</returns> public override string ModifyValues(Qso2 qso) { string mod = null; Station_Callsign call = qso.GetField("Station_Callsign") as Station_Callsign; if(call == null) { call = new Station_Callsign(Value); qso.Fields.Add(call); call.ModifyValues(qso); mod = "\tStation_Callsign field generated from Operator field." + Environment.NewLine; } return mod; }
/// <summary> /// Generate Owner_Callsign field if it does not exist /// </summary> /// <param name="qso">Qso2 object containing this field</param> /// <returns>string indicating changes made</returns> public override string ModifyValues(Qso2 qso) { string mod = null; Owner_Callsign owner = qso.GetField("Owner_Callsign") as Owner_Callsign; if(owner == null) { owner = new Owner_Callsign(Value); qso.Fields.Add(owner); owner.ModifyValues(qso); mod = "\tOwner_Callsign field generated from Station_Callsign" + Environment.NewLine; } return mod; }
public void TestModifyValuesWithInvalidModeNoSubmode() { string err = string.Empty; Qso2 qso = new Qso2("<Mode:6>SQUIBB", aEnums, ref err); AdifField field = qso.GetField("Mode"); Assert.IsNotNull(field); Mode mode = field as Mode; Assert.IsNotNull(mode); Assert.AreEqual("\tMode not found in Mode enumeration. Submode set to mode value and mode cleared.", mode.ModifyValues(qso)); Assert.AreEqual(null, qso["Mode"]); Submode submode = qso.GetField("Submode") as Submode; Assert.IsNotNull(submode); Assert.AreEqual("SQUIBB", submode.Value); }
public void TestAddMediumToExistingCredit() { string err = string.Empty; Qso2 qso = new Qso2("<Credit_Granted:49>DXCC:CARD&LOTW,DXCC_MODE:CARD&LOTW,DXCC_BAND:CARD", aEnums, ref err); Credit_Granted granted = qso.GetField("Credit_Granted") as Credit_Granted; List<Credit> creds = granted.GetCredits("DXCC"); Assert.AreEqual(1, creds.Count); Assert.AreEqual(2, creds[0].Media.Count); Assert.AreEqual("DXCC:CARD&LOTW", creds[0].ToString()); granted.Add(new Credit("DXCC:EQSL", aEnums)); creds = granted.GetCredits("DXCC"); Assert.AreEqual(3, creds[0].Media.Count); Assert.AreEqual("DXCC:CARD&LOTW&EQSL", creds[0].ToString()); Assert.IsTrue(creds[0].IsInMedia("EQSL")); }
/// <summary> /// Change VE_PROV to STATE /// </summary> /// <param name="qso">Qso2 object containing this field</param> /// <returns>string indicating the change made</returns></returns> public override string ModifyValues(Qso2 qso) { string mod = null; State state = qso.GetField("State") as State; if(state == null) { state = new State(Value); qso.Fields.Add(state); mod = "\tVE_Prov field deprecated. VE_Prov field deleted and replaced with State field." + Environment.NewLine; state.ModifyValues(qso); } else { mod = "\tVE_Prov field deprecated. State field already exists, so VE_Prov field deleted." + Environment.NewLine; } qso.Fields.Remove(this); return mod; }
/// <summary> /// Delete this field and change to Operator field if that does not already exist. /// </summary> /// <param name="qso">Qso2 object containing this field</param> /// <returns>Message indicating any modifications made</returns> public override string ModifyValues(Qso2 qso) { string mod = null; Operator op = qso.GetField("Operator") as Operator; if(op == null) { op = new Operator(Value); qso.Fields.Add(op); mod = "\tGuest_Op field changed to Operator field." + Environment.NewLine; string mod2 = op.ModifyValues(qso); if(mod2 != null) { mod += mod2; } } else { mod = "\tGuest_Op field cannot be changed to Operator field because Operator field already exists. Guest_Op field deleted." + Environment.NewLine; } qso.Fields.Remove(this); return mod; }