pEpForiOSTests/UI/Compose/ViewModel/ComposeViewModel+InitDataTest.swift
author Alejandro Gelos <agp@pep.security>
Tue, 20 Aug 2019 15:37:15 +0200
branchIOS-1758
changeset 9728 2d762ad64237
parent 9694 1f5c53be567d
permissions -rw-r--r--
IOS-1758 minor renaming and removing unneeded code
     1 //
     2 //  ComposeViewModel+InitDataTest.swift
     3 //  pEpForiOSTests
     4 //
     5 //  Created by Andreas Buff on 13.11.18.
     6 //  Copyright © 2018 p≡p Security S.A. All rights reserved.
     7 //
     8 
     9 import XCTest
    10 
    11 @testable import pEpForiOS
    12 @testable import MessageModel
    13 
    14 class ComposeViewModel_InitDataTest: CoreDataDrivenTestBase {
    15     var inbox: Folder?
    16     var drafts: Folder?
    17     var outbox: Folder?
    18     var messageAllButBccSet: Message?
    19     var testee: ComposeViewModel.InitData?
    20     var someone: Identity!
    21 
    22     override func setUp() {
    23         super.setUp()
    24 
    25         someone = Identity(address: "someone@someone.someone")
    26 
    27         // Folders
    28         let inbox = Folder(name: "Inbox", parent: nil, account: account, folderType: .inbox)
    29         inbox.save()
    30         self.inbox = inbox
    31         let drafts = Folder(name: "Drafts", parent: inbox, account: account, folderType: .drafts)
    32         drafts.save()
    33         self.drafts = drafts
    34         let outbox = Folder(name: "Outbox", parent: nil, account: account, folderType: .outbox)
    35         outbox.save()
    36         self.outbox = outbox
    37         let msg = Message(uuid: UUID().uuidString, parentFolder: inbox)
    38         msg.from = account.user
    39         msg.replaceTo(with: [account.user, someone])
    40         msg.replaceCc(with: [someone])
    41         msg.shortMessage = "shortMessage"
    42         msg.longMessage = "longMessage"
    43         msg.longMessageFormatted = "longMessageFormatted"
    44         msg.replaceAttachments(with: [Attachment(data: Data(),
    45                                                  mimeType: "image/jpg",
    46                                                  contentDisposition: .attachment)])
    47         msg.appendToAttachments(Attachment(data: Data(),
    48                                            mimeType: "image/jpg",
    49                                            contentDisposition: .inline))
    50         msg.save()
    51         messageAllButBccSet = msg
    52 
    53         someone.save()
    54     }
    55 
    56     override func tearDown() {
    57         inbox = nil
    58         drafts = nil
    59         outbox = nil
    60         messageAllButBccSet = nil
    61         testee = nil
    62         super.tearDown()
    63     }
    64 
    65     // MARK: - prefilledTo
    66 
    67     func testPrefilledTo_set() {
    68         let mode = ComposeUtil.ComposeMode.normal
    69         testee = ComposeViewModel.InitData(withPrefilledToRecipient: someone,
    70                                            orForOriginalMessage: nil,
    71                                            composeMode: mode)
    72         let expectedTo: [Identity] = [someone]
    73         assertTesteeForExpectedValues(composeMode: mode,
    74                                       isDraftsOrOutbox: false,
    75                                       isDrafts: false,
    76                                       isOutbox: false,
    77                                       pEpProtection: true,
    78                                       from: account.user,
    79                                       toRecipients: expectedTo,
    80                                       ccRecipients: [],
    81                                       bccRecipients: [],
    82                                       subject: " ",
    83                                       bodyPlaintext: "",
    84                                       bodyHtml: nil,
    85                                       nonInlinedAttachments: [],
    86                                       inlinedAttachments: [])
    87     }
    88 
    89     func testPrefilledTo_notSet() {
    90         let mode = ComposeUtil.ComposeMode.normal
    91         testee = ComposeViewModel.InitData(withPrefilledToRecipient: nil,
    92                                            orForOriginalMessage: nil,
    93                                            composeMode: mode)
    94         let expectedTo = [Identity]()
    95         assertTesteeForExpectedValues(composeMode: mode,
    96                                       isDraftsOrOutbox: false,
    97                                       isDrafts: false,
    98                                       isOutbox: false,
    99                                       pEpProtection: true,
   100                                       from: account.user,
   101                                       toRecipients: expectedTo,
   102                                       ccRecipients: [],
   103                                       bccRecipients: [],
   104                                       subject: " ",
   105                                       bodyPlaintext: "",
   106                                       bodyHtml: nil,
   107                                       nonInlinedAttachments: [],
   108                                       inlinedAttachments: [])
   109     }
   110 
   111     func testPrefilledTo_originalMessageWins() {
   112         let mode = ComposeUtil.ComposeMode.normal
   113         testee = ComposeViewModel.InitData(withPrefilledToRecipient: nil,
   114                                            orForOriginalMessage: messageAllButBccSet,
   115                                            composeMode: mode)
   116         let expectedTo = [Identity]()
   117         assertTesteeForExpectedValues(composeMode: mode,
   118                                       isDraftsOrOutbox: false,
   119                                       isDrafts: false,
   120                                       isOutbox: false,
   121                                       pEpProtection: true,
   122                                       from: account.user,
   123                                       toRecipients: expectedTo,
   124                                       ccRecipients: [],
   125                                       bccRecipients: [],
   126                                       subject: " ",
   127                                       bodyPlaintext: "",
   128                                       bodyHtml: nil,
   129                                       nonInlinedAttachments: [],
   130                                       inlinedAttachments: [])
   131     }
   132 
   133     func testPrefilledFrom_set() {
   134         let mode = ComposeUtil.ComposeMode.normal
   135         testee = ComposeViewModel.InitData(prefilledFromSender:someone)
   136         let expectedFrom = someone
   137         assertTesteeForExpectedValues(composeMode: mode,
   138                                       isDraftsOrOutbox: false,
   139                                       isDrafts: false,
   140                                       isOutbox: false,
   141                                       pEpProtection: true,
   142                                       from: expectedFrom,
   143                                       toRecipients: nil,
   144                                       ccRecipients: [],
   145                                       bccRecipients: [],
   146                                       subject: " ",
   147                                       bodyPlaintext: "",
   148                                       bodyHtml: nil,
   149                                       nonInlinedAttachments: [],
   150                                       inlinedAttachments: [])
   151     }
   152     // MARK: - originalMessage
   153 
   154     func testOriginalMessage_isSet() {
   155         let mode = ComposeUtil.ComposeMode.normal
   156         let originalMessage = messageAllButBccSet
   157         testee = ComposeViewModel.InitData(withPrefilledToRecipient: nil,
   158                                            orForOriginalMessage: originalMessage,
   159                                            composeMode: mode)
   160         let expectedTo = [Identity]()
   161         assertTesteeForExpectedValues(composeMode: mode,
   162                                       originalMessage: originalMessage,
   163                                       isDraftsOrOutbox: false,
   164                                       isDrafts: false,
   165                                       isOutbox: false,
   166                                       pEpProtection: true,
   167                                       from: account.user,
   168                                       toRecipients: expectedTo,
   169                                       ccRecipients: [],
   170                                       bccRecipients: [],
   171                                       subject: " ",
   172                                       bodyPlaintext: "",
   173                                       bodyHtml: nil,
   174                                       nonInlinedAttachments: [],
   175                                       inlinedAttachments: [])
   176     }
   177 
   178     func testOriginalMessage_alsoSetWithGivenPrefilledTo() {
   179         let mode = ComposeUtil.ComposeMode.normal
   180         let originalMessage = messageAllButBccSet
   181         testee = ComposeViewModel.InitData(withPrefilledToRecipient: someone,
   182                                            orForOriginalMessage: originalMessage,
   183                                            composeMode: mode)
   184         let expectedTo = [Identity]()
   185         assertTesteeForExpectedValues(composeMode: mode,
   186                                       originalMessage: originalMessage,
   187                                       isDraftsOrOutbox: false,
   188                                       isDrafts: false,
   189                                       isOutbox: false,
   190                                       pEpProtection: true,
   191                                       from: account.user,
   192                                       toRecipients: expectedTo,
   193                                       ccRecipients: [],
   194                                       bccRecipients: [],
   195                                       subject: " ",
   196                                       bodyPlaintext: "",
   197                                       bodyHtml: nil,
   198                                       nonInlinedAttachments: [],
   199                                       inlinedAttachments: [])
   200     }
   201 
   202     // MARK: - composeMode
   203 
   204     func testComposeMode_default() {
   205         let mode: ComposeUtil.ComposeMode? = nil
   206         testee = ComposeViewModel.InitData(withPrefilledToRecipient: nil,
   207                                            orForOriginalMessage: nil,
   208                                            composeMode: mode)
   209         let defaultComposeMode = ComposeUtil.ComposeMode.normal
   210         assertTesteeForExpectedValues(composeMode: defaultComposeMode)
   211     }
   212 
   213     func testComposeMode_isSet_normal() {
   214         let mode = ComposeUtil.ComposeMode.normal
   215         testee = ComposeViewModel.InitData(withPrefilledToRecipient: nil,
   216                                            orForOriginalMessage: nil,
   217                                            composeMode: mode)
   218         let expectedComposeMode = mode
   219         assertTesteeForExpectedValues(composeMode: expectedComposeMode)
   220     }
   221 
   222     func testComposeMode_isSet_notNormal() {
   223         let mode = ComposeUtil.ComposeMode.replyFrom
   224         testee = ComposeViewModel.InitData(withPrefilledToRecipient: nil,
   225                                            orForOriginalMessage: nil,
   226                                            composeMode: mode)
   227         let expectedComposeMode = mode
   228         assertTesteeForExpectedValues(composeMode: expectedComposeMode)
   229     }
   230 
   231     func testComposeMode_fromInbox_normal() {
   232         let mode = ComposeUtil.ComposeMode.normal
   233         guard let originalMessage = messageAllButBccSet else {
   234             XCTFail("No message")
   235             return
   236         }
   237         let expectedHtmlBody: NSAttributedString? = nil
   238         assertComposeMode(mode,
   239                           originalMessage: originalMessage,
   240                           expectedHtmlBody: expectedHtmlBody)
   241     }
   242 
   243     func testComposeMode_fromInbox_forward() {
   244         let mode = ComposeUtil.ComposeMode.forward
   245         guard let originalMessage = messageAllButBccSet else {
   246             XCTFail("No message")
   247             return
   248         }
   249         let expectedSubject = ReplyUtil.forwardSubject(message: originalMessage)
   250         // Body
   251         guard let origBodyAttributedString =
   252             originalMessage.longMessageFormatted?.htmlToAttributedString(attachmentDelegate: nil)
   253             else {
   254                 XCTFail("No body")
   255                 return
   256         }
   257         let expectedHtmlBody = ReplyUtil.citedMessageText(textToCite: origBodyAttributedString,
   258                                                           fromMessage: originalMessage)
   259         assertComposeMode(mode,
   260                           originalMessage: originalMessage,
   261                           expectedSubject: expectedSubject,
   262                           expectedHtmlBody: expectedHtmlBody)
   263     }
   264 
   265     func testComposeMode_fromInbox_replyFrom() {
   266         let mode = ComposeUtil.ComposeMode.replyFrom
   267         guard let originalMessage = messageAllButBccSet else {
   268             XCTFail("No message")
   269             return
   270         }
   271         let expectedSubject = ReplyUtil.replySubject(message: originalMessage)
   272         let expectedBody = ReplyUtil.quotedMessageText(message: originalMessage,
   273                                                        replyAll: false)
   274         assertComposeMode(mode,
   275                           originalMessage: originalMessage,
   276                           expectedSubject: expectedSubject,
   277                           expectedPlaintextBody: expectedBody,
   278                           expectedHtmlBody: nil)
   279     }
   280 
   281     func testComposeMode_fromInbox_replyAll() {
   282         let mode = ComposeUtil.ComposeMode.replyAll
   283         guard let originalMessage = messageAllButBccSet else {
   284             XCTFail("No message")
   285             return
   286         }
   287         let expectedSubject = ReplyUtil.replySubject(message: originalMessage)
   288         let expectedBody = ReplyUtil.quotedMessageText(message: originalMessage,
   289                                                        replyAll: true)
   290         assertComposeMode(mode,
   291                           originalMessage: originalMessage,
   292                           expectedSubject: expectedSubject,
   293                           expectedPlaintextBody: expectedBody,
   294                           expectedHtmlBody: nil)
   295     }
   296 
   297     func testComposeMode_fromDrafts() {
   298         let mode = ComposeUtil.ComposeMode.normal
   299         guard
   300             let originalMessage = messageAllButBccSet,
   301             let drafts = drafts,
   302             let origSubject = originalMessage.shortMessage,
   303             let htmlBody =
   304             originalMessage.longMessageFormatted?.htmlToAttributedString(attachmentDelegate: nil)
   305             else {
   306                 XCTFail()
   307                 return
   308         }
   309         originalMessage.parent = drafts
   310         let expectedSubject = origSubject
   311         let expectedHtmlBody = htmlBody
   312         assertComposeMode(mode,
   313                           originalMessage: originalMessage,
   314                           expectedSubject: expectedSubject,
   315                           expectedHtmlBody: expectedHtmlBody)
   316     }
   317 
   318     func testComposeMode_fromOutbox() {
   319         let mode = ComposeUtil.ComposeMode.normal
   320         guard
   321             let originalMessage = messageAllButBccSet,
   322             let outbox = outbox,
   323             let origSubject = originalMessage.shortMessage,
   324             let htmlBody =
   325             originalMessage.longMessageFormatted?.htmlToAttributedString(attachmentDelegate: nil)
   326             else {
   327                 XCTFail()
   328                 return
   329         }
   330         originalMessage.parent = outbox
   331         let expectedSubject = origSubject
   332         let expectedHtmlBody = htmlBody
   333         assertComposeMode(mode,
   334                           originalMessage: originalMessage,
   335                           expectedSubject: expectedSubject,
   336                           expectedHtmlBody: expectedHtmlBody)
   337     }
   338 
   339     // MARK: - isDraftsOrOutbox isDrafts isOutbox
   340 
   341     func testIsDraftsOrOutbox_noOrigMessage() {
   342         let mode = ComposeUtil.ComposeMode.normal
   343         testee = ComposeViewModel.InitData(withPrefilledToRecipient: nil,
   344                                            orForOriginalMessage: nil,
   345                                            composeMode: mode)
   346         assertTesteeIsDraftsAndOrOutbox(originalMessage: nil)
   347     }
   348 
   349     func testIsDraftsOrOutbox_inbox() {
   350         guard let parent = inbox else {
   351             XCTFail("No folder")
   352             return
   353         }
   354         assertIsDraftsAndOrOutbox(forOriginalMessageWithParentFolder: parent)
   355     }
   356 
   357     func testIsDraftsOrOutbox_drafts() {
   358         guard let parent = drafts else {
   359             XCTFail("No folder")
   360             return
   361         }
   362         assertIsDraftsAndOrOutbox(forOriginalMessageWithParentFolder: parent)
   363     }
   364 
   365     func testIsDraftsOrOutbox_outbox() {
   366         guard let parent = outbox else {
   367             XCTFail("No folder")
   368             return
   369         }
   370         assertIsDraftsAndOrOutbox(forOriginalMessageWithParentFolder: parent)
   371     }
   372 
   373     // MARK: - from, toRecipients, ccRecipients, bccRecipients, subject, body, inlinedAttachments & nonInlinedAttachments
   374     // are already tested in compos mode tests
   375 
   376     // MARK: - pEpProtection
   377 
   378     func testPEpProtection_noOriginalMessage() {
   379         let mode = ComposeUtil.ComposeMode.normal
   380         testee = ComposeViewModel.InitData(withPrefilledToRecipient: nil,
   381                                            orForOriginalMessage: nil,
   382                                            composeMode: mode)
   383         let expectedProtected = true
   384         assertTesteeForExpectedValues(pEpProtection: expectedProtected)
   385     }
   386 
   387     func testPEpProtection_originalMessage() {
   388         let mode = ComposeUtil.ComposeMode.normal
   389         guard let om = messageAllButBccSet else {
   390             XCTFail("No message")
   391             return
   392         }
   393         testee = ComposeViewModel.InitData(withPrefilledToRecipient: nil,
   394                                            orForOriginalMessage: om,
   395                                            composeMode: mode)
   396         let expectedProtected = om.pEpProtected
   397         assertTesteeForExpectedValues(pEpProtection: expectedProtected)
   398     }
   399 
   400     // MARK: - nonInlinedAttachments
   401 
   402     func testNonInlinedAttachments() {
   403         ComposeUtil.ComposeMode.allCases.forEach {
   404             assertNonInlinedAttachments(forComposeMode: $0)
   405         }
   406     }
   407 
   408     // MARK: - inlinedAttachments
   409 
   410     func testInlinedAttachments() {
   411         ComposeUtil.ComposeMode.allCases.forEach {
   412             assertInlinedAttachments(forComposeMode: $0)
   413         }
   414     }
   415 
   416     // MARK: - Helper
   417 
   418     private func assertNonInlinedAttachments(forComposeMode mode: ComposeUtil.ComposeMode) {
   419         assertAttachments(orType: .attachment, forComposeMode: mode)
   420     }
   421 
   422     private func assertInlinedAttachments(forComposeMode mode: ComposeUtil.ComposeMode) {
   423         assertAttachments(orType: .inline, forComposeMode: mode)
   424     }
   425 
   426     private func assertAttachments(orType contentDisposition: Attachment.ContentDispositionType,
   427                                    forComposeMode mode: ComposeUtil.ComposeMode) {
   428         guard let om = messageAllButBccSet else {
   429             XCTFail("No message")
   430             return
   431         }
   432         testee = ComposeViewModel.InitData(withPrefilledToRecipient: someone,
   433                                            orForOriginalMessage: om,
   434                                            composeMode: mode)
   435         let expectedAttachments =
   436             ComposeUtil.initialAttachments(composeMode: mode,
   437                                            contentDisposition: contentDisposition,
   438                                            originalMessage: om)
   439         let expectedInlinedAttachments =
   440             contentDisposition == .inline ? expectedAttachments : nil
   441         let expectedNonInlinedAttachments =
   442             contentDisposition == .attachment ? expectedAttachments : nil
   443         assertTesteeForExpectedValues(nonInlinedAttachments: expectedNonInlinedAttachments,
   444                                       inlinedAttachments: expectedInlinedAttachments)
   445     }
   446 
   447     private func assertIsDraftsAndOrOutbox(forOriginalMessageWithParentFolder folder: Folder) {
   448         let mode = ComposeUtil.ComposeMode.normal
   449         messageAllButBccSet?.parent = folder
   450         let originalMessage = messageAllButBccSet
   451         testee = ComposeViewModel.InitData(withPrefilledToRecipient: nil,
   452                                            orForOriginalMessage: originalMessage,
   453                                            composeMode: mode)
   454         assertTesteeIsDraftsAndOrOutbox(originalMessage: originalMessage)
   455     }
   456 
   457     private func assertTesteeIsDraftsAndOrOutbox(originalMessage: Message?) {
   458         var expectedIsDrafts = false
   459         var expectedIsOutbox = false
   460         var expectedIsDraftsOrOutbox = false
   461         if let om = originalMessage  {
   462             if om.parent.folderType == .drafts {
   463                 expectedIsDrafts = true
   464             } else if om.parent.folderType == .outbox {
   465                 expectedIsOutbox = true
   466             }
   467             expectedIsDraftsOrOutbox = expectedIsDrafts || expectedIsOutbox
   468         }
   469         assertTesteeForExpectedValues(isDraftsOrOutbox: expectedIsDraftsOrOutbox,
   470                                       isDrafts: expectedIsDrafts,
   471                                       isOutbox: expectedIsOutbox)
   472     }
   473 
   474     private func assertComposeMode(_ composeMode: ComposeUtil.ComposeMode,
   475                                    originalMessage: Message,
   476                                    expectedSubject: String = " ",
   477                                    expectedPlaintextBody: String = "",
   478                                    expectedHtmlBody: NSAttributedString?) {
   479         let mode = composeMode
   480         testee = ComposeViewModel.InitData(withPrefilledToRecipient: nil,
   481                                            orForOriginalMessage: originalMessage,
   482                                            composeMode: mode)
   483         let expectedTos = ComposeUtil.initialTos(composeMode: mode,
   484                                                  originalMessage: originalMessage)
   485         let expectedCcs = ComposeUtil.initialCcs(composeMode: mode,
   486                                                  originalMessage: originalMessage)
   487         let expectedBccs = ComposeUtil.initialBccs(composeMode: mode,
   488                                                    originalMessage: originalMessage)
   489         let expectedInlinedAttachments =
   490             ComposeUtil.initialAttachments(composeMode: mode,
   491                                            contentDisposition: .inline,
   492                                            originalMessage: originalMessage)
   493         let expectedNonInlinedAttachments =
   494             ComposeUtil.initialAttachments(composeMode: mode,
   495                                            contentDisposition: .attachment,
   496                                            originalMessage: originalMessage)
   497         assertTesteeForExpectedValues(composeMode: mode,
   498                                       originalMessage: originalMessage,
   499                                       isDraftsOrOutbox: nil,
   500                                       isDrafts: nil,
   501                                       isOutbox: nil,
   502                                       pEpProtection: true,
   503                                       from: account.user,
   504                                       toRecipients: expectedTos,
   505                                       ccRecipients: expectedCcs,
   506                                       bccRecipients: expectedBccs,
   507                                       subject: expectedSubject,
   508                                       bodyPlaintext: expectedPlaintextBody,
   509                                       bodyHtml: expectedHtmlBody,
   510                                       nonInlinedAttachments: expectedNonInlinedAttachments,
   511                                       inlinedAttachments: expectedInlinedAttachments)
   512     }
   513 
   514     /// Asserts the testee for the given values. Optional arguments set to `nil` are ignored.
   515     private func assertTesteeForExpectedValues( composeMode: ComposeUtil.ComposeMode? = nil,
   516                                                 originalMessage: Message? = nil,
   517                                                 isDraftsOrOutbox: Bool? = nil,
   518                                                 isDrafts: Bool? = nil,
   519                                                 isOutbox: Bool? = nil,
   520                                                 pEpProtection: Bool? = nil,
   521                                                 from: Identity? = nil,
   522                                                 toRecipients: [Identity]? = nil,
   523                                                 ccRecipients: [Identity]? = nil,
   524                                                 bccRecipients: [Identity]? = nil,
   525                                                 subject: String? = nil,
   526                                                 bodyPlaintext: String? = nil,
   527                                                 bodyHtml: NSAttributedString? = nil,
   528                                                 nonInlinedAttachments: [Attachment]? = nil,
   529                                                 inlinedAttachments: [Attachment]? = nil) {
   530         guard let testee = testee else {
   531             XCTFail("No testee")
   532             return
   533         }
   534         if let exp = composeMode {
   535             XCTAssertEqual(testee.composeMode, exp)
   536         }
   537         if let exp = originalMessage {
   538             XCTAssertEqual(testee.originalMessage, exp)
   539         }
   540         if let exp = isDraftsOrOutbox {
   541             XCTAssertEqual(testee.isDraftsOrOutbox, exp)
   542         }
   543         if let exp = isDrafts {
   544             XCTAssertEqual(testee.isDrafts, exp)
   545         }
   546         if let exp = isOutbox {
   547             XCTAssertEqual(testee.isOutbox, exp)
   548         }
   549         if let exp = pEpProtection {
   550             XCTAssertEqual(testee.pEpProtection, exp)
   551         }
   552         if let exp = from {
   553             XCTAssertEqual(testee.from, exp)
   554         }
   555         if let exp = toRecipients {
   556             XCTAssertEqual(testee.toRecipients, exp)
   557             XCTAssertEqual(testee.toRecipients.count, exp.count)
   558             for to in testee.toRecipients {
   559                 XCTAssertTrue(exp.contains(to))
   560             }
   561         }
   562         if let exp = ccRecipients {
   563             XCTAssertEqual(testee.ccRecipients, exp)
   564             XCTAssertEqual(testee.ccRecipients.count, exp.count)
   565             for to in testee.ccRecipients {
   566                 XCTAssertTrue(exp.contains(to))
   567             }
   568         }
   569         if let exp = bccRecipients {
   570             XCTAssertEqual(testee.bccRecipients, exp)
   571             XCTAssertEqual(testee.bccRecipients.count, exp.count)
   572             for to in testee.bccRecipients {
   573                 XCTAssertTrue(exp.contains(to))
   574             }
   575         }
   576         if let exp = subject {
   577             XCTAssertEqual(testee.subject, exp)
   578         }
   579         if let exp = bodyPlaintext {
   580             XCTAssertEqual(testee.bodyPlaintext, exp)
   581         }
   582         if let exp = bodyHtml {
   583             XCTAssertEqual(testee.bodyHtml, exp)
   584         }
   585         if let exp = nonInlinedAttachments {
   586             XCTAssertEqual(testee.nonInlinedAttachments, exp)
   587             XCTAssertEqual(testee.nonInlinedAttachments.count, exp.count)
   588             for to in testee.nonInlinedAttachments {
   589                 XCTAssertTrue(exp.contains(to))
   590             }
   591         }
   592         if let exp = inlinedAttachments {
   593             XCTAssertEqual(testee.inlinedAttachments, exp)
   594             XCTAssertEqual(testee.inlinedAttachments.count, exp.count)
   595             for to in testee.inlinedAttachments {
   596                 XCTAssertTrue(exp.contains(to))
   597             }
   598         }
   599     }
   600 }