private static void _Tests_MailboxName(string pMailboxPath, bool pExpectFail, cTrace.cContext pParentContext) { var lContext = pParentContext.NewMethod(nameof(cMailboxName), nameof(_Tests_MailboxName), pMailboxPath); cCommandPartFactory lFactory; cCommandPart lCommandPart; cBytesCursor lCursor; IList <byte> lEncodedMailboxPath; cMailboxName lMailboxName; lFactory = new cCommandPartFactory(false, null); if (!lFactory.TryAsMailbox(pMailboxPath, '/', out lCommandPart, out _)) { throw new cTestsException($"mailboxname conversion failed on '{pMailboxPath}'"); } cTextCommandPart lTCP = lCommandPart as cTextCommandPart; lCursor = new cBytesCursor(lTCP.Bytes); lCursor.GetAString(out lEncodedMailboxPath); if (cMailboxName.TryConstruct(lEncodedMailboxPath, cASCII.SLASH, false, out lMailboxName)) { if (pExpectFail) { throw new cTestsException($"mailboxname construction succeeded on '{pMailboxPath}' and it shouldn't have"); } } else { if (!pExpectFail) { throw new cTestsException($"mailboxname construction failed on '{pMailboxPath}' and it shouldn't have"); } return; } if (lMailboxName.Path != pMailboxPath) { throw new cTestsException($"mailboxname conversion failed on '{pMailboxPath}' -> {lTCP.Bytes} -> '{lMailboxName}'", lContext); } lFactory = new cCommandPartFactory(true, null); lFactory.TryAsMailbox(pMailboxPath, '/', out lCommandPart, out _); lTCP = lCommandPart as cTextCommandPart; lCursor = new cBytesCursor(lTCP.Bytes); lCursor.GetAString(out lEncodedMailboxPath); cMailboxName.TryConstruct(lEncodedMailboxPath, cASCII.SLASH, true, out lMailboxName); if (lMailboxName.Path != pMailboxPath) { throw new cTestsException($"mailboxname conversion failed on '{pMailboxPath}' -> {lTCP.Bytes} -> '{lMailboxName}'", lContext); } }
private cMailboxCacheItem ZItem(cMailboxName pMailboxName) { if (pMailboxName == null) { throw new ArgumentNullException(nameof(pMailboxName)); } if (!mCommandPartFactory.TryAsMailbox(pMailboxName.Path, pMailboxName.Delimiter, out var lCommandPart, out var lEncodedMailboxPath)) { throw new ArgumentOutOfRangeException(nameof(pMailboxName)); } var lItem = mDictionary.GetOrAdd(lEncodedMailboxPath, new cMailboxCacheItem(mSynchroniser, this, lEncodedMailboxPath)); lItem.MailboxName = pMailboxName; lItem.MailboxNameCommandPart = lCommandPart; return(lItem); }