public static void ClassInit(TestContext context) { Context = new XrmFakedContext(); Context.ProxyTypesAssembly = Assembly.GetAssembly(typeof(ProxyTypesAssembly)); Plugin = Context.GetDefaultPluginContext(); }
public IServiceProvider CreateServiceProvider(XrmFakedPluginExecutionContext plugCtx) => GetFakedServiceProvider(plugCtx);
private void SetupMock() { FakedServices = MockOptions.FakedServices; FakedServices.AddHttpMock(); //Setup Facked Context FakedContext = new XrmFakedContext { ProxyTypesAssembly = MockOptions.ProxyTypesAssembly }; //Build system store foreach (Entity entity in MockOptions.Store) { AddFakeData(entity); } foreach (MockRelationship relationship in MockOptions.Relationships) { FakedContext.AddRelationship(relationship.RelationshipName, (XrmFakedRelationship)relationship); } var fakedService = FakedContext.GetFakedOrganizationService(); foreach (AssociateRequest associationRequest in MockOptions.AssociateRequests) { fakedService.Execute(associationRequest); } if (typeof(TExecutionContext) == typeof(XrmFakedPluginExecutionContext)) { XrmFakedPluginExecutionContext executionContext = FakedContext.GetDefaultPluginContext(); executionContext.InputParameters = MockOptions.InputParameters; executionContext.CorrelationId = Guid.NewGuid(); executionContext.OperationId = Guid.NewGuid(); Guard.That(() => MockOptions.Message).IsNotNullOrEmpty(); executionContext.MessageName = MockOptions.Message; Guard.That(() => MockOptions.UserId).IsNotEqual(Guid.Empty); executionContext.UserId = MockOptions.UserId; executionContext.PrimaryEntityName = MockOptions.PrimaryEntityName; FakedExecutionContext = executionContext as TExecutionContext; } else if (typeof(TExecutionContext) == typeof(XrmFakedWorkflowContext)) { XrmFakedWorkflowContext executionContext = FakedContext.GetDefaultWorkflowContext(); executionContext.InputParameters = MockOptions.InputParameters; executionContext.CorrelationId = Guid.NewGuid(); executionContext.OperationId = Guid.NewGuid(); Guard.That(() => MockOptions.Message).IsNotNullOrEmpty(); executionContext.MessageName = MockOptions.Message; Guard.That(() => MockOptions.UserId).IsNotEqual(Guid.Empty); executionContext.UserId = MockOptions.UserId; executionContext.PrimaryEntityName = MockOptions.PrimaryEntityName; FakedExecutionContext = executionContext as TExecutionContext; } Guard.That(() => FakedExecutionContext).IsNotNull(); Setup(); }
public void TestInititalize() { Context = new XrmFakedContext(); TracingService = Context.GetFakeTracingService(); PluginContext = Context.GetDefaultPluginContext(); }