     }
     
     func testIndexBasedUpdateMethodByDuplicatingKey() {
-        var orderedDictionary: OrderedDictionary<String, Int> = ["A": 1, "B": 2, "C": 3]
-        
-        XCTAssertThrowsError(try orderedDictionary.update((key: "A", value: 3), at: 2)) { error in
-            XCTAssertEqual(error as? OrderedDictionaryError, OrderedDictionaryError.nonUniqueKey("A"))
-        }
+        let orderedDictionary: OrderedDictionary<String, Int> = ["A": 1, "B": 2, "C": 3]
+        
+        let element = (key: "A", value: 42)
+        
+        XCTAssertTrue(orderedDictionary.canUpdate(element, at: 0))
+        XCTAssertFalse(orderedDictionary.canUpdate(element, at: 1))
+        XCTAssertFalse(orderedDictionary.canUpdate(element, at: 2))
     }
     
     func testRetrievingElementAtNonExistentIndex() {

    }
    
    func testIndexBasedInsertionWithDuplicateKey() {
        var orderedDictionary: OrderedDictionary<String, Int> = ["A": 1, "B": 2, "C": 3]
        
        XCTAssertThrowsError(try orderedDictionary.insert((key: "A", value: 42), at: 3)) { error in
            XCTAssertEqual(error as? OrderedDictionaryError, OrderedDictionaryError.nonUniqueKey("A"))
        }
    }
    
    // ======================================================= //

    
    func testIndexBasedUpdateMethodByReplacingSameKey() {
        var orderedDictionary: OrderedDictionary<String, Int> = ["A": 1, "B": 2, "C": 3]
        let previousElement = orderedDictionary.update((key: "B", value: 42), at: 1)
        
        XCTAssertEqual(orderedDictionary.count, 3)
        XCTAssertTrue(previousElement! == ("B", 2))
