import { Observable , AsyncSubject , ReplaySubject , Subject } from 'rxjs' ; import { SignalRConfiguration } from '../signalr.configuration' ; import { BroadcastEventListener } from '../eventing/broadcast.event.listener' ; import { ConnectionStatus } from '../connection/connection.status' ; import { ISignalRConnection } from '../connection/i.signalr.connection' ; export interface IListenerCollection { [ name ] : BroadcastEventListener < any > ; } export class SignalRConnectionMock implements ISignalRConnection { constructor ( private _mockErrors$ , private _mockStatus$ , private _listeners ) { } get errors ( ) : Observable < any > { return this . _mockErrors$ ; } get status ( ) : Observable < ConnectionStatus > { return this . _mockStatus$ . asObservable ( ) ; } get id ( ) : string { return 'xxxxxxxx-xxxx-xxxx-xxxxxxxxx' ; } public stop ( ) { } public start ( ) { return Promise . resolve ( null ) ; } public invoke ( method , ... parameters ) { return Promise . resolve ( null ) ; } public listen < T > ( listener ) { this . _listeners [ listener . event ] = listener ; } public listenFor < T > ( event ) { const listener = new BroadcastEventListener < T > ( event ) ; this . listen ( listener ) ; return listener ; } public listenForRaw ( event ) { const listener = new BroadcastEventListener < any [ ] > ( event ) ; this . _listeners [ listener . event ] = listener ; return listener ; } stopListening < T > ( listener ) { delete this . _listeners [ listener . event ] ; } }