/// <summary> /// Initialises a new instance using the specified <see cref="cMessage"/> properties. /// </summary> /// <param name="pProperties">The message properties to cache the backing data for.</param> public cMessageCacheItems(fMessageProperties pProperties) { Attributes = 0; // see comments elsewhere as to why mdnsent is commented out if ((pProperties & (fMessageProperties.flags | fMessageProperties.answered | fMessageProperties.flagged | fMessageProperties.deleted | fMessageProperties.seen | fMessageProperties.draft | fMessageProperties.recent | /* fMessageProperties.mdnsent | */ fMessageProperties.forwarded | fMessageProperties.submitpending | fMessageProperties.submitted)) != 0) { Attributes |= fMessageCacheAttributes.flags; } if ((pProperties & (fMessageProperties.envelope | fMessageProperties.sent | fMessageProperties.subject | fMessageProperties.basesubject | fMessageProperties.from | fMessageProperties.sender | fMessageProperties.replyto | fMessageProperties.to | fMessageProperties.cc | fMessageProperties.bcc | fMessageProperties.inreplyto | fMessageProperties.messageid)) != 0) { Attributes |= fMessageCacheAttributes.envelope; } if ((pProperties & fMessageProperties.received) != 0) { Attributes |= fMessageCacheAttributes.received; } if ((pProperties & fMessageProperties.size) != 0) { Attributes |= fMessageCacheAttributes.size; } if ((pProperties & fMessageProperties.bodystructure | fMessageProperties.attachments | fMessageProperties.plaintextsizeinbytes) != 0) { Attributes |= fMessageCacheAttributes.bodystructure; } if ((pProperties & fMessageProperties.uid) != 0) { Attributes |= fMessageCacheAttributes.uid; } if ((pProperties & fMessageProperties.modseq) != 0) { Attributes |= fMessageCacheAttributes.modseq; } cHeaderFieldNameList lNames = new cHeaderFieldNameList(); if ((pProperties & fMessageProperties.references) != 0) { lNames.Add(kHeaderFieldName.References); } if ((pProperties & fMessageProperties.importance) != 0) { lNames.Add(kHeaderFieldName.Importance); } Names = new cHeaderFieldNames(lNames); }
internal static void _Tests(cTrace.cContext pParentContext) { var lContext = pParentContext.NewMethod(nameof(cHeaderFieldNameList), nameof(_Tests)); cHeaderFieldNameList lNames1; cHeaderFieldNameList lNames2; cHeaderFieldNameList lNames3; cHeaderFieldNameList lNames4; if (!TryConstruct(new string[] { }, out lNames1) || lNames1.Count != 0) { throw new cTestsException($"{nameof(cHeaderFieldNames)}.1.1"); } if (!TryConstruct(new string[] { "fred", "angus" }, out lNames1) || !TryConstruct(new string[] { "AnGuS", "ANGUS", "FrEd" }, out lNames2) || !lNames1.Contains(lNames2) || !lNames2.Contains(lNames1)) { throw new cTestsException($"{nameof(cHeaderFieldNames)}.1.2"); } if (!TryConstruct(new string[] { "fred", "charlie" }, out lNames3) || !TryConstruct(new string[] { "CHARLie", "mAx" }, out lNames4) || lNames3.Contains(lNames4) || lNames4.Contains(lNames3)) { throw new cTestsException($"{nameof(cHeaderFieldNames)}.1.3"); } if (lNames2.Contains("max") || !lNames2.Contains("FREd") || !lNames4.Contains("max") || lNames4.Contains("FREd")) { throw new cTestsException($"{nameof(cHeaderFieldNames)}.1.4"); } lNames2 = new cHeaderFieldNameList(lNames1); lNames2.Add("fReD"); if ((cHeaderFieldNames)lNames1 != lNames2) { throw new cTestsException($"{nameof(cHeaderFieldNames)}.1.5"); } lNames2.Add("charlie"); if (lNames2.Count != 3 || !lNames2.Contains("Fred") || !lNames2.Contains("ANgUS") || !lNames2.Contains("CHArLIE")) { throw new cTestsException($"{nameof(cHeaderFieldNames)}.1.6"); } var lNames5 = lNames1.Union(lNames3); if ((cHeaderFieldNames)lNames5 != lNames2) { throw new cTestsException($"{nameof(cHeaderFieldNames)}.1.7"); } lNames2 = lNames1.Intersect(lNames3); if (lNames2.Count != 1 || !lNames2.Contains("fReD")) { throw new cTestsException($"{nameof(cHeaderFieldNames)}.1.8"); } lNames2 = lNames5.Except(lNames4); if (lNames2.Count != 2 || (cHeaderFieldNames)lNames2 != lNames1) { throw new cTestsException($"{nameof(cHeaderFieldNames)}.1.9"); } bool lFailed = false; try { cHeaderFieldNames lF = new cHeaderFieldNames("dd ff"); } catch { lFailed = true; } if (!lFailed) { throw new cTestsException($"{nameof(cHeaderFieldNames)}.1.13"); } lFailed = false; try { cHeaderFieldNames lF = new cHeaderFieldNames("dd:ff"); } catch { lFailed = true; } if (!lFailed) { throw new cTestsException($"{nameof(cHeaderFieldNames)}.1.14"); } }