import Foundation

public class Mock<Interaction: Equatable> {
    public var interactions: [Interaction] = []

    public init() {}
}

// MARK: - Basics

public func record<Interaction: Equatable>(mock: Mock<Interaction>, interaction: Interaction) {
    mock.interactions.append(interaction)
}

// MARK: - Verification

public func verify<Interaction: Equatable, S: SequenceType where S.Generator.Element == Interaction>(mock: Mock<Interaction>, interactions: S) -> Bool {
    var generator = interactions.generate()
    var element = generator.next()

    for interaction in mock.interactions {
        if interaction == element {
            element = generator.next()
        }
    }

    return element == nil
}

import Foundation

public class Mock<Interaction: Equatable> {
    public var interactions: [Interaction] = []

    public init() {}
}

// MARK: - Basics

public func record<Interaction: Equatable>(mock: Mock<Interaction>, interaction: Interaction) {
    mock.interactions.append(interaction)
}

// MARK: - Verification

public func verify<Interaction: Equatable, C: CollectionType where C.Generator.Element == Interaction>(mock: Mock<Interaction>, interactions: C) -> Bool {
    var index = interactions.startIndex
    for interaction in mock.interactions {
        if interaction == interactions[index] {
            index = advance(index, 1)
            if index == interactions.endIndex {
                return true
            }
        }
    }

    return false
}

--- 
+++ 
@@ -14,16 +14,15 @@
 
 // MARK: - Verification
 
-public func verify<Interaction: Equatable, C: CollectionType where C.Generator.Element == Interaction>(mock: Mock<Interaction>, interactions: C) -> Bool {
-    var index = interactions.startIndex
+public func verify<Interaction: Equatable, S: SequenceType where S.Generator.Element == Interaction>(mock: Mock<Interaction>, interactions: S) -> Bool {
+    var generator = interactions.generate()
+    var element = generator.next()
+
     for interaction in mock.interactions {
-        if interaction == interactions[index] {
-            index = advance(index, 1)
-            if index == interactions.endIndex {
-                return true
-            }
+        if interaction == element {
+            element = generator.next()
         }
     }
 
-    return false
+    return element == nil
 }
Verify sequences instead of collections
