Ejemplo n.º 1
0
 public void TestIsInMediaFalse()
 {
     Assembly assembly = Assembly.GetAssembly((new AdifField()).GetType());
     Stream str = assembly.GetManifestResourceStream("hamqsler.AdifEnumerations.xml");
     AdifEnumerations aEnums = new AdifEnumerations(str);
     Credit credit = new Credit("IOTA:Card&Lotw&eQSL", aEnums);
     Assert.IsFalse(credit.IsInMedia("QRZCOM"));
 }
Ejemplo n.º 2
0
 public void TestCreditNameNoMedium()
 {
     Assembly assembly = Assembly.GetAssembly((new AdifField()).GetType());
     Stream str = assembly.GetManifestResourceStream("hamqsler.AdifEnumerations.xml");
     AdifEnumerations aEnums = new AdifEnumerations(str);
     Credit credit = new Credit("IOTA", aEnums);
     Assert.AreEqual("IOTA", credit.CreditName);
 }
Ejemplo n.º 3
0
 public void TestIsInMediaNull()
 {
     Assembly assembly = Assembly.GetAssembly((new AdifField()).GetType());
     Stream str = assembly.GetManifestResourceStream("hamqsler.AdifEnumerations.xml");
     AdifEnumerations aEnums = new AdifEnumerations(str);
     Credit credit = new Credit("IOTA", aEnums);
     Assert.IsTrue(credit.IsInMedia(null));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructor
 /// Note: no validation of input is performed in the constructor. Call Validate after
 /// the constructor and when changing values.
 /// </summary>
 /// <param name="credits">string containing credits informatin</param>
 /// <param name="aEnums">AdifEnumerations object containing the Award, Credit, and
 /// QSL Medium enumerations</param>
 public CreditList(string credits, AdifEnumerations aEnums)
 {
     string[] creds = credits.Split(',');
     foreach(string credit in creds)
     {
         Credit c = new Credit(credit.Trim(' ').ToUpper(), aEnums);
         this.Add(c);
     }
 }
Ejemplo n.º 5
0
 public void TestAddSingleCredit()
 {
     Credit credit = new Credit("IOTA", aEnums);
     CreditList list = new CreditList();
     list.Add(credit);
     Assert.AreEqual(1, list.Count);
     List<Credit> credits = list.GetCredits("IOTA");
     Assert.AreEqual(1, credits.Count);
     Assert.AreEqual("IOTA", credits[0].CreditName);
     string[] media = new string[credits[0].Media.Count];
     credits[0].Media.CopyTo(media);
     Assert.AreEqual(null, media[0]);
 }
Ejemplo n.º 6
0
 public void TestMediaNoMedia()
 {
     Assembly assembly = Assembly.GetAssembly((new AdifField()).GetType());
     Stream str = assembly.GetManifestResourceStream("hamqsler.AdifEnumerations.xml");
     AdifEnumerations aEnums = new AdifEnumerations(str);
     Credit credit = new Credit("IOTA", aEnums);
     string[] media = new string[credit.Media.Count];
     credit.Media.CopyTo(media);
     Assert.IsNull(media[0]);
 }
Ejemplo n.º 7
0
 public void TestGetCreditsNoMatchingCredits()
 {
     Credit credit = new Credit("IOTA", aEnums);
     CreditList list = new CreditList();
     list.Add(credit);
     Credit notIOTA = new Credit("WAS", aEnums);
     list.Add(notIOTA);
     Credit credit2 = new Credit("IOTA:Card&Lotw", aEnums);
     list.Add(credit2);
     List<Credit> credits = list.GetCredits("WAB");
     Assert.AreEqual(0, credits.Count);
 }
Ejemplo n.º 8
0
 public void TestGetCreditsTwoMatchingCredits()
 {
     Credit credit = new Credit("IOTA", aEnums);
     CreditList list = new CreditList();
     list.Add(credit);
     Credit notIOTA = new Credit("WAS", aEnums);
     list.Add(notIOTA);
     Credit credit2 = new Credit("IOTA:Card&Lotw", aEnums);
     list.Add(credit2);
     List<Credit> credits = list.GetCredits("IOTA");
     Assert.AreEqual(2, credits.Count);
     Assert.AreEqual("IOTA", credits[0].CreditName);
     string[] media = new string[credits[0].Media.Count];
     credits[0].Media.CopyTo(media);
     Assert.AreEqual(null, media[0]);
     Assert.AreEqual("IOTA", credits[1].CreditName);
     media = new string[credits[1].Media.Count];
     credits[1].Media.CopyTo(media);
     Assert.AreEqual("CARD", media[0]);
     Assert.AreEqual("LOTW", media[1]);
 }
Ejemplo n.º 9
0
 public void TestAddTwoCreditsDifferentMedia()
 {
     Credit credit = new Credit("IOTA:EQSL&LOTW", aEnums);
     CreditList list = new CreditList();
     list.Add(credit);
     Credit c2 = new Credit("IOTA:CARD", aEnums);
     list.Add(c2);
     Assert.AreEqual(1, list.Count);
     List<Credit> credits = list.GetCredits("IOTA");
     Assert.AreEqual(1, credits.Count);
     Assert.AreEqual("IOTA", credits[0].CreditName);
     string[] media = new string[credits[0].Media.Count];
     credits[0].Media.CopyTo(media);
     Assert.AreEqual(3, media.Length);
     Assert.AreEqual("EQSL", media[0]);
     Assert.AreEqual("LOTW", media[1]);
     Assert.AreEqual("CARD", media[2]);
 }
Ejemplo n.º 10
0
 public void TestAddTwoCreditsNullAndMedium()
 {
     Credit credit = new Credit("IOTA", aEnums);
     CreditList list = new CreditList();
     list.Add(credit);
     Assert.AreEqual(1, list.Count);
     Credit c2 = new Credit("IOTA:CARD", aEnums);
     list.Add(c2);
     Assert.AreEqual(2, list.Count);
     List<Credit> credits = list.GetCredits("IOTA");
     Assert.AreEqual(2, credits.Count);
     Assert.AreEqual("IOTA", credits[0].CreditName);
     string[] media = new string[credits[0].Media.Count];
     credits[0].Media.CopyTo(media);
     Assert.AreEqual(null, media[0]);
     media = new string[credits[1].Media.Count];
     credits[1].Media.CopyTo(media);
     Assert.AreEqual(1, media.Length);
     Assert.AreEqual("CARD", media[0]);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Replace Awards with Credits if there are equivalents
 /// </summary>
 /// <param name="mod"></param>
 public void ReplaceAwardsWithCredits(ref string mod)
 {
     mod = null;
     Credit[] creds = new Credit[Credits.Count];
     Credits.CopyTo(creds);
     string err = string.Empty;
     string modStr = string.Empty;
     foreach(Credit credit in creds)
     {
         bool inEnumeration =  credit.Validate(out err, out modStr);
         if(!inEnumeration)
         {
             string replacement = credit.AdifEnums.GetCreditEquivalentForAward(credit.CreditName);
             if(replacement == null)
             {
                 Credits.Remove(credit);
                 mod += string.Format("\t\tAward '{0}' deleted because there is no equivalent Credit." +
                                      Environment.NewLine, credit.CreditName);
             }
             else
             {
                 Credits.Remove(credit);
                 this.Add(new Credit(replacement, credit.AdifEnums));
                 mod += string.Format("\t\tAward '{0}' replaced with Credit '{1}'." +
                                      Environment.NewLine, credit, replacement);
             }
         }
     }
 }
Ejemplo n.º 12
0
 public void TestToStringCreditAndSingleMedium()
 {
     Assembly assembly = Assembly.GetAssembly((new AdifField()).GetType());
     Stream str = assembly.GetManifestResourceStream("hamqsler.AdifEnumerations.xml");
     AdifEnumerations aEnums = new AdifEnumerations(str);
     Credit credit = new Credit("IOTA:CARD&Lotw", aEnums);
     Assert.AreEqual("IOTA:CARD&LOTW", credit.ToString());
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Add credit to credit list. If a Credit object of same name already exists with media,
 /// just add the media
 /// </summary>
 /// <param name="item">Credit object to add</param>
 public void Add(Credit item)
 {
     List<Credit> credits = GetCredits(item.CreditName);
     if(credits.Count == 0)
     {
         creditList.Add(item);
         return;
     }
     string[] itemMedia = new string[item.Media.Count];
     item.Media.CopyTo(itemMedia);
     foreach(Credit credit in credits)
     {
         if(credit.CreditName.Equals(item.CreditName))
      	{
             string[] media = new string[credit.Media.Count];
             credit.Media.CopyTo(media);
             if(itemMedia[0] == null && media[0] == null)
             {
                 return;
             }
             else if(itemMedia[0] != null && media[0] != null)
             {
                 foreach(string it in itemMedia)
                 {
                     credit.Media.Add(it);
                 }
                 return;
             }
         }
     }
     creditList.Add(item);
 }
Ejemplo n.º 14
0
 public void TestMediaTwoMedia()
 {
     Assembly assembly = Assembly.GetAssembly((new AdifField()).GetType());
     Stream str = assembly.GetManifestResourceStream("hamqsler.AdifEnumerations.xml");
     AdifEnumerations aEnums = new AdifEnumerations(str);
     Credit credit = new Credit("IOTA:Lotw&card", aEnums);
     string[] media = new string[credit.Media.Count];
     credit.Media.CopyTo(media);
     Assert.AreEqual("LOTW", media[0]);
     Assert.AreEqual("CARD", media[1]);
 }
Ejemplo n.º 15
0
 public void TestValidateValidCreditNoMedia()
 {
     Assembly assembly = Assembly.GetAssembly((new AdifField()).GetType());
     Stream str = assembly.GetManifestResourceStream("hamqsler.AdifEnumerations.xml");
     AdifEnumerations aEnums = new AdifEnumerations(str);
     Credit credit = new Credit("IOTA", aEnums);
     string err = string.Empty;
     string modStr = string.Empty;
     Assert.IsTrue(credit.Validate(out err, out modStr));
     Assert.IsNull(err);
     Assert.IsNull(modStr);
 }
Ejemplo n.º 16
0
 public void TestValidateValidCreditNullAndValidMedia()
 {
     Assembly assembly = Assembly.GetAssembly((new AdifField()).GetType());
     Stream str = assembly.GetManifestResourceStream("hamqsler.AdifEnumerations.xml");
     AdifEnumerations aEnums = new AdifEnumerations(str);
     Credit credit = new Credit("IOTA", aEnums);
     credit.Media.Add("Card");
     credit.Media.Add("LotW");
     string err = string.Empty;
     string modStr = string.Empty;
     Assert.IsFalse(credit.Validate(out err, out modStr));
     Assert.AreEqual("\tProgramming Error: Credit object cannot contain both null and other QSL Media", err);
     Assert.IsNull(modStr);
 }
Ejemplo n.º 17
0
 public void TestValidateValidCreditSingleInvalidMedia()
 {
     Assembly assembly = Assembly.GetAssembly((new AdifField()).GetType());
     Stream str = assembly.GetManifestResourceStream("hamqsler.AdifEnumerations.xml");
     AdifEnumerations aEnums = new AdifEnumerations(str);
     Credit credit = new Credit("IOTA:crad", aEnums);
     string err = string.Empty;
     string modStr =string.Empty;
     Assert.IsFalse(credit.Validate(out err, out modStr));
     Assert.AreEqual("\t'CRAD' not found in QSL Medium enumeration", err);
     Assert.IsNull(modStr);
 }