export class ItemCollectionMock < T > implements Xrm . Collection . ItemCollection < T > { public itemCollection : T [ ] ; constructor ( itemCollection ? ) { this . itemCollection = itemCollection || [ ] ; } public forEach ( delegate ) ; public forEach ( delegate ) ; public forEach ( delegate ) { this . itemCollection . map ( delegate ) ; } public get ( delegate ) ; public get ( item ) ; public get ( ) ; public get ( param ? ) { if ( param === undefined || param === null ) { return ( this . itemCollection as T [ ] ) ; } else if ( typeof param === "string" ) { let attribute ; for ( const item of this . itemCollection as any ) { if ( item . getName !== undefined && item . getName ( ) === param ) { attribute = item ; break ; } } return attribute || null ; } else if ( typeof param === "number" ) { return this . itemCollection [ param ] || null ; } else { return this . itemCollection . filter ( param as Xrm . Collection . MatchingDelegate < T > ) ; } } public getLength ( ) { return this . itemCollection . length ; } public push ( item ) { this . itemCollection . push ( item ) ; } }