/// <summary>
        ///     Prepare instance variables, plugin context, and mocks.
        /// </summary>
        protected void SetupEnvironment()
        {
            OrganizationService       = service;
            SystemOrganizationService = service;

            // we need the organisation name to add it to the plugin context
            if (orgName == null)
            {
                var whoAmI = (WhoAmIResponse)service.Execute(new WhoAmIRequest());
                userId           = whoAmI.UserId;
                initiatingUserId = whoAmI.UserId;
                businessUnitId   = whoAmI.BusinessUnitId;
                orgId            = whoAmI.OrganizationId;
                orgName          = service.Retrieve("organization", orgId,
                                                    new ColumnSet("name")).GetAttributeValue <string>("name");
            }

            if (!commonSetup)
            {
                SetupCommon();
                commonSetup = true;
            }

            // add user, business unit, and organisation info to the plugin context
            PluginExecutionContextMock.Setup(contextT => contextT.UserId).Returns(userId);
            PluginExecutionContextMock.Setup(contextT => contextT.InitiatingUserId).Returns(userId);
            PluginExecutionContextMock.Setup(contextT => contextT.BusinessUnitId).Returns(businessUnitId);
            PluginExecutionContextMock.Setup(contextT => contextT.OrganizationId).Returns(orgId);
            PluginExecutionContextMock.Setup(contextT => contextT.OrganizationName).Returns(orgName);

            // any plugin instance requesting a service will get this one
            OrganizationServiceFactoryMock.Setup(factory => factory.CreateOrganizationService(It.IsAny <Guid?>())).Returns(OrganizationService);
        }
示例#2
0
 public AbstractTest()
 {
     _tracingService  = new TracingServiceTest();
     _service         = new OrganizationServiceMock();
     _serviceProvider = new ServiceProviderMock()
     {
         Service = _service
     };
     _pluginExecutionContext = new PluginExecutionContextMock();
 }
 /// <summary>
 ///     Sets the initiating user ID for the plugin.
 /// </summary>
 /// <param name="userIdL">The user ID</param>
 protected void SetInitiatingUser(Guid userIdL)
 {
     PluginExecutionContextMock.Setup(contextT => contextT.InitiatingUserId).Returns(userIdL);
 }