camelCaseDave/xrm-mock

View on GitHub
src/xrm-mock-generator/eventcontext.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import * as XrmMock from "../xrm-mock/index";
import Context from "./context";
import FormContext from "./formcontext";
import Ui from "./ui";

export default class EventContext {
  public static Context: Context = new Context();
  public static FormContext: FormContext = new FormContext();

  public static createEventContext(entity?: XrmMock.IEntityComponents, context?: Xrm.GlobalContext, formContext?: Xrm.FormContext,
                                   ui?: XrmMock.IUiComponents, process?: Xrm.ProcessFlow.ProcessManager): XrmMock.EventContextMock {
    const eventContext = new XrmMock.EventContextMock({
      context: context || Context.createContext(),
      formContext: formContext || FormContext.createFormContext(entity, ui, process),
    });
    return eventContext;
  }
}