import { ControlMock , IAttControlComponents , IControlComponents } from "../control/control.mock" ; export class GridControlMock extends ControlMock implements Xrm . Controls . GridControl { private static defaultComponents ( components ) { components . controlType = "subgrid" ; components . contextType = components . contextType || 4 as XrmEnum . GridControlContext . FormContextRelated ; components . entityName = components . entityName || "contact" ; components . onLoadHandlers = components . onLoadHandlers || [ ] ; return components ; } public onLoadHandlers : Xrm . Events . ContextSensitiveHandler [ ] ; public contextType : XrmEnum . GridControlContext ; public entityName : string ; public viewSelector ? : Xrm . Controls . ViewSelector ; public grid ? : Xrm . Controls . Grid ; public relationship ? : Xrm . Navigation . Relationship ; constructor ( components ) { super ( GridControlMock . defaultComponents ( components ) ) ; this . contextType = components . contextType ; this . entityName = components . entityName ; this . onLoadHandlers = components . onLoadHandlers ; this . viewSelector = components . viewSelector ; this . grid = components . grid ; this . relationship = components . relationship ; } public setVisible ( visible ) { throw new Error ( "Method not implemented." ) ; } public refreshRibbon ( ) { throw new Error ( "Method not implemented." ) ; } public addOnLoad ( handler ) { this . onLoadHandlers . push ( handler ) ; } public getContextType ( ) { return this . contextType ; } public getEntityName ( ) { return this . entityName ; } public getGrid ( ) { return this . grid ; } public getViewSelector ( ) { return this . viewSelector ; } public refresh ( ) { throw new Error ( "Method not implemented." ) ; } public removeOnLoad ( handler ) { for ( let i = this . onLoadHandlers . length - 1 ; i >= 0 ; i -- ) { const func = this . onLoadHandlers [ i ] ; if ( func === handler ) { this . onLoadHandlers . splice ( i , 1 ) ; break ; } } } public getFetchXml ( ) { throw new Error ( "getFetchXml not implemented." ) ; } public getGridType ( ) { throw new Error ( "getGridType not implemented." ) ; } public getRelationship ( ) { return this . relationship ; } public getUrl ( client ) { throw new Error ( "getUrl not implemented." ) ; } public openRelatedGrid ( ) { throw new Error ( "openRelatedGrid not implemented." ) ; } } export interface IGridControlComponents extends IAttGridControlComponents , IControlComponents { name : string ; viewSelector ? : Xrm . Controls . ViewSelector ; grid ? : Xrm . Controls . Grid ; relationship ? : Xrm . Navigation . Relationship ; } export interface IAttGridControlComponents extends IAttControlComponents { contextType ? : XrmEnum . GridControlContext ; entityName ? : string ; name ? : string ; onLoadHandlers ? : Xrm . Events . ContextSensitiveHandler [ ] ; }