export class EventContextMock implements Xrm . Events . EventContext { public context : Xrm . GlobalContext ; public depth : number ; public eventArgs : Xrm . Events . SaveEventContext ; public eventSource : Xrm . Attributes . Attribute | Xrm . Controls . Control | Xrm . Entity ; public formContext : Xrm . FormContext ; public sharedVariables : { [ index ] : any ; } ; constructor ( components ) { this . context = components . context ; this . depth = components . depth === undefined || components . depth === null ? 1 : components . depth ; this . eventArgs = components . eventArgs ; this . eventSource = components . eventSource ; this . formContext = components . formContext ; this . sharedVariables = components . sharedVariables || { } ; } public getContext ( ) { return this . context ; } public getDepth ( ) { return this . depth ; } public getEventArgs ( ) { if ( this . eventArgs ) { return this . eventArgs ; } throw new Error ( "no event args given" ) ; } public getEventSource ( ) { if ( this . eventSource ) { return this . eventSource ; } throw new Error ( "no event source given" ) ; } public getFormContext ( ) { return this . formContext ; } public getSharedVariable < T > ( key ) { return this . sharedVariables [ key ] ; } public setSharedVariable < T > ( key , value ) { this . sharedVariables [ key ] = value ; } } export interface IEventContextComponents { context ? : Xrm . GlobalContext ; depth ? : number ; eventArgs ? : Xrm . Events . SaveEventContext ; eventSource ? : Xrm . Attributes . Attribute | Xrm . Controls . Control | Xrm . Entity ; formContext ? : Xrm . FormContext ; sharedVariables ? : { [ index ] : any ; } ; }