func testDispose()

in OSSSwiftDemo/OSSSwiftDemoTests/OSSCancellationTests.swift [121:149]


    func testDispose() {
        var cts = OSSCancellationTokenSource()
        cts.dispose()
        
        XCTAssertThrowsError(cts.cancel(), NSExceptionName.internalInconsistencyException.rawValue) { (error) in
            XCTAssertNotNil(error)
        }
        XCTAssertThrowsError(cts.isCancellationRequested, NSExceptionName.internalInconsistencyException.rawValue) { (error) in
            XCTAssertNotNil(error)
        }
        XCTAssertThrowsError(cts.token.isCancellationRequested, NSExceptionName.internalInconsistencyException.rawValue) { (error) in
            XCTAssertNotNil(error)
        }
        
        cts = OSSCancellationTokenSource()
        cts.cancel()
        
        XCTAssertTrue(cts.isCancellationRequested, "Source should be cancelled")
        XCTAssertTrue(cts.token.isCancellationRequested, "Token should be cancelled")
        
        cts.dispose()
        
        XCTAssertThrowsError(cts.isCancellationRequested, NSExceptionName.internalInconsistencyException.rawValue) { (error) in
            XCTAssertNotNil(error)
        }
        XCTAssertThrowsError(cts.token.isCancellationRequested, NSExceptionName.internalInconsistencyException.rawValue) { (error) in
            XCTAssertNotNil(error)
        }
    }