Пример #1
0
        public UnitTestBase(XrmMockupFixture fixture)
        {
            crm = fixture.crm;
            crm.ResetEnvironment();
            orgAdminUIService = crm.GetAdminService(new MockupServiceSettings(true, false, MockupServiceSettings.Role.UI));
            orgGodService     = crm.GetAdminService(new MockupServiceSettings(false, true, MockupServiceSettings.Role.SDK));
            orgAdminService   = crm.GetAdminService();
            if (fixture.crmRealData != null)
            {
                orgRealDataService = fixture.crmRealData.GetAdminService();
            }

            //create an admin user to run our impersonating user plugins as
            var adminUser = new Entity("systemuser")
            {
                Id = Guid.Parse("3b961284-cd7a-4fa3-af7e-89802e88dd5c")
            };

            adminUser["businessunitid"]       = crm.RootBusinessUnit;
            adminUser["internalemailaddress"] = "*****@*****.**";
            adminUser["islicensed"]           = true;

            adminUser = crm.CreateUser(orgAdminService, adminUser, SecurityRoles.SystemAdministrator);

            InitialiseAccessTeamConfiguration();
        }
Пример #2
0
        public UnitTestBaseNoReset(XrmMockupFixture fixture)
        {
            crm = fixture.crm;
            orgAdminUIService = crm.GetAdminService(new MockupServiceSettings(true, false, MockupServiceSettings.Role.UI));
            orgGodService     = crm.GetAdminService(new MockupServiceSettings(false, true, MockupServiceSettings.Role.SDK));
            orgAdminService   = crm.GetAdminService();
            if (fixture.crmRealData != null)
            {
                orgRealDataService = fixture.crmRealData.GetAdminService();
            }

            //create an admin user to run our impersonating user plugins as

            var userQuery = new QueryExpression("systemuser");

            userQuery.Criteria.AddCondition("systemuserid", ConditionOperator.Equal, Guid.Parse("3b961284-cd7a-4fa3-af7e-89802e88dd5c"));
            var users = orgAdminService.RetrieveMultiple(userQuery);

            if (users.Entities.SingleOrDefault() == null)
            {
                var adminUser = new Entity("systemuser")
                {
                    Id = Guid.Parse("3b961284-cd7a-4fa3-af7e-89802e88dd5c")
                };
                adminUser["businessunitid"] = crm.RootBusinessUnit;
                adminUser = crm.CreateUser(orgAdminService, adminUser, SecurityRoles.SystemAdministrator);
            }
        }
Пример #3
0
    public XrmMockupFixture()
    {
        var settings = new XrmMockupSettings
        {
            BasePluginTypes           = new Type[] { typeof(Plugin), typeof(PluginNonDaxif) },
            CodeActivityInstanceTypes = new Type[] { typeof(AccountWorkflowActivity) },
            EnableProxyTypes          = true,
            IncludeAllWorkflows       = false,
            ExceptionFreeRequests     = new string[] { "TestWrongRequest" },
            MetadataDirectoryPath     = "../../../Metadata",
            IPluginMetadata           = metaPlugins
        };

#if XRM_MOCKUP_TEST_2011
        crm = XrmMockup2011.GetInstance(settings);
#elif XRM_MOCKUP_TEST_2013
        crm = XrmMockup2013.GetInstance(settings);
#elif XRM_MOCKUP_TEST_2015
        crm = XrmMockup2015.GetInstance(settings);
#elif XRM_MOCKUP_TEST_2016
        crm = XrmMockup2016.GetInstance(settings);
#elif XRM_MOCKUP_TEST_365
        crm = XrmMockup365.GetInstance(settings);
#endif
        try
        {
            var realDataSettings = new XrmMockupSettings
            {
                BasePluginTypes           = settings.BasePluginTypes,
                CodeActivityInstanceTypes = settings.CodeActivityInstanceTypes,
                EnableProxyTypes          = settings.EnableProxyTypes,
                IncludeAllWorkflows       = settings.IncludeAllWorkflows,
                ExceptionFreeRequests     = settings.ExceptionFreeRequests,
                OnlineEnvironment         = new Env
                {
                    providerType = AuthenticationProviderType.OnlineFederation,
                    uri          = "https://exampleURL/XRMServices/2011/Organization.svc",
                    username     = "******",
                    password     = "******"
                }
            };
#if XRM_MOCKUP_TEST_2011
            crmRealData = XrmMockup2011.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2013
            crmRealData = XrmMockup2013.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2015
            crmRealData = XrmMockup2015.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2016
            crmRealData = XrmMockup2016.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_365
            crmRealData = XrmMockup365.GetInstance(realDataSettings);
#endif
        }
        catch
        {
            // ignore
        }
    }
 public UnitTestBaseNoProxyTypes(XrmMockupFixtureNoProxyTypes fixture)
 {
     crm = fixture.crm;
     crm.ResetEnvironment();
     orgAdminUIService = crm.GetAdminService(new MockupServiceSettings(true, false, MockupServiceSettings.Role.UI));
     orgGodService     = crm.GetAdminService(new MockupServiceSettings(false, true, MockupServiceSettings.Role.SDK));
     orgAdminService   = crm.GetAdminService();
     if (fixture.crmRealData != null)
     {
         orgRealDataService = fixture.crmRealData.GetAdminService();
     }
 }
Пример #5
0
        public static void InitializeMockup(TestContext context)
        {
            var settings = new XrmMockupSettings {
                BasePluginTypes           = new Type[] { typeof(DG.Some.Namespace.Plugin), typeof(PluginNonDaxif) },
                CodeActivityInstanceTypes = new Type[] { typeof(AccountWorkflowActivity) },
                EnableProxyTypes          = true,
                IncludeAllWorkflows       = false,
                ExceptionFreeRequests     = new string[] { "TestWrongRequest" },
            };

            var realDataSettings = new XrmMockupSettings {
                BasePluginTypes           = settings.BasePluginTypes,
                CodeActivityInstanceTypes = settings.CodeActivityInstanceTypes,
                EnableProxyTypes          = settings.EnableProxyTypes,
                IncludeAllWorkflows       = settings.IncludeAllWorkflows,
                ExceptionFreeRequests     = settings.ExceptionFreeRequests,
                OnlineEnvironment         = new Env {
                    providerType = AuthenticationProviderType.OnlineFederation,
                    uri          = "https://delegatelab4.crm4.dynamics.com/XRMServices/2011/Organization.svc",
                    username     = "******",
                    password     = "******"
                }
            };

#if XRM_MOCKUP_TEST_2011
            crm         = XrmMockup2011.GetInstance(settings);
            crmRealData = XrmMockup2011.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2013
            crm         = XrmMockup2013.GetInstance(settings);
            crmRealData = XrmMockup2013.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2015
            crm         = XrmMockup2015.GetInstance(settings);
            crmRealData = XrmMockup2015.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2016
            crm         = XrmMockup2016.GetInstance(settings);
            crmRealData = XrmMockup2016.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_365
            crm         = XrmMockup365.GetInstance(settings);
            crmRealData = XrmMockup365.GetInstance(realDataSettings);
#endif
        }
Пример #6
0
        public static void InitializeMockup(TestContext context)
        {
            var settings = new XrmMockupSettings {
                BasePluginTypes           = new Type[] { typeof(Plugin), typeof(PluginNonDaxif) },
                CodeActivityInstanceTypes = new Type[] { typeof(AccountWorkflowActivity) },
                EnableProxyTypes          = true,
                IncludeAllWorkflows       = false,
                ExceptionFreeRequests     = new string[] { "TestWrongRequest" }
            };

#if XRM_MOCKUP_TEST_2011
            crm = XrmMockup2011.GetInstance(settings);
#elif XRM_MOCKUP_TEST_2013
            crm = XrmMockup2013.GetInstance(settings);
#elif XRM_MOCKUP_TEST_2015
            crm = XrmMockup2015.GetInstance(settings);
#elif XRM_MOCKUP_TEST_2016
            crm = XrmMockup2016.GetInstance(settings);
#elif XRM_MOCKUP_TEST_365
            crm = XrmMockup365.GetInstance(settings);
#endif
        }
Пример #7
0
        public static void InitializeMockup(TestContext context)
        {
            var additionalPluginMetadata = new MetaPlugin();

            additionalPluginMetadata.AssemblyName  = "DG.Some.Namespace.ContactIPluginDirectPreOp";
            additionalPluginMetadata.MessageName   = "Create";
            additionalPluginMetadata.PrimaryEntity = "contact";
            additionalPluginMetadata.Rank          = 10;
            additionalPluginMetadata.Stage         = 20; //pre op as it only updates a field name

            var additionalPluginMetadata2 = new MetaPlugin();

            additionalPluginMetadata2.AssemblyName  = "DG.Some.Namespace.ContactIPluginDirectPostOp";
            additionalPluginMetadata2.MessageName   = "Create";
            additionalPluginMetadata2.PrimaryEntity = "contact";
            additionalPluginMetadata2.Rank          = 10;
            additionalPluginMetadata2.Stage         = 40; //postOp

            var settings = new XrmMockupSettings
            {
                BasePluginTypes           = new Type[] { typeof(Plugin), typeof(PluginNonDaxif), typeof(ContactIPluginDirectPreOp) },
                CodeActivityInstanceTypes = new Type[] { typeof(AccountWorkflowActivity) },
                EnableProxyTypes          = true,
                IncludeAllWorkflows       = false,
                ExceptionFreeRequests     = new string[] { "TestWrongRequest" },
                MetadataDirectoryPath     = "../../../Metadata",
                IPluginMetadata           = new MetaPlugin[] { additionalPluginMetadata, additionalPluginMetadata2 }
                //MetadataDirectoryPath = @"C:\dev\MOD\CAMS\Plugins\XrmMockupTests\Metadata"
                , DatabaseConnectionString = "Server=.;Database=XrmMockup;Trusted_Connection=True;"
                , RecreateDatabase         = false
                                             //,RetainTables = new string[] { "fax" ,"goal","lead"}
                                             //  ,AppendAndAppendToPrivilegeCheck = false
            };

#if XRM_MOCKUP_TEST_2011
            crm = XrmMockup2011.GetInstance(settings);
#elif XRM_MOCKUP_TEST_2013
            crm = XrmMockup2013.GetInstance(settings);
#elif XRM_MOCKUP_TEST_2015
            crm = XrmMockup2015.GetInstance(settings);
#elif XRM_MOCKUP_TEST_2016
            crm = XrmMockup2016.GetInstance(settings);
#elif XRM_MOCKUP_TEST_365
            crm = XrmMockup365.GetInstance(settings);
#endif

            try
            {
                var realDataSettings = new XrmMockupSettings
                {
                    BasePluginTypes           = settings.BasePluginTypes,
                    CodeActivityInstanceTypes = settings.CodeActivityInstanceTypes,
                    EnableProxyTypes          = settings.EnableProxyTypes,
                    IncludeAllWorkflows       = settings.IncludeAllWorkflows,
                    ExceptionFreeRequests     = settings.ExceptionFreeRequests,
                    OnlineEnvironment         = new Env
                    {
                        providerType = AuthenticationProviderType.OnlineFederation,
                        uri          = "https://exampleURL/XRMServices/2011/Organization.svc",
                        username     = "******",
                        password     = "******"
                    }
                };
#if XRM_MOCKUP_TEST_2011
                crmRealData = XrmMockup2011.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2013
                crmRealData = XrmMockup2013.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2015
                crmRealData = XrmMockup2015.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2016
                crmRealData = XrmMockup2016.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_365
                crmRealData = XrmMockup365.GetInstance(realDataSettings);
#endif
            }
            catch
            {
                // ignore
            }
        }
Пример #8
0
        public static void InitializeMockup(TestContext context)
        {
            var settings = new XrmMockupSettings
            {
                BasePluginTypes           = new Type[] { typeof(DG.Some.Namespace.Plugin), typeof(PluginNonDaxif) },
                CodeActivityInstanceTypes = new Type[] { typeof(AccountWorkflowActivity) },
                EnableProxyTypes          = true,
                IncludeAllWorkflows       = false,
                ExceptionFreeRequests     = new string[] { "TestWrongRequest" },
            };

            string workFlowAssembliesPath = WebConfigurationManager.AppSettings["CompiledWorkflowAssembliesPath"];
            var    librariesToIgnore      = new List <string>()
            {
                "Microsoft."
            };


#if XRM_MOCKUP_TEST_2011
            crm = XrmMockup2011.GetInstance(settings);
#elif XRM_MOCKUP_TEST_2013
            crm = XrmMockup2013.GetInstance(settings);
            var customWorkflowTypes = new List <Type>()
            {
                typeof(CodeActivity)
            };
            crm.RegisterWorkflowCodeActivitiesFromExternalAssemblies(workFlowAssembliesPath, customWorkflowTypes, librariesToIgnore);
#elif XRM_MOCKUP_TEST_2015
            crm = XrmMockup2015.GetInstance(settings);
            var customWorkflowTypes = new List <Type>()
            {
                typeof(CodeActivity)
            };
            crm.RegisterWorkflowCodeActivitiesFromExternalAssemblies(workFlowAssembliesPath, customWorkflowTypes, librariesToIgnore);
#elif XRM_MOCKUP_TEST_2016
            crm = XrmMockup2016.GetInstance(settings);
            var customWorkflowTypes = new List <Type>()
            {
                typeof(CodeActivity)
            };
            crm.RegisterWorkflowCodeActivitiesFromExternalAssemblies(workFlowAssembliesPath, customWorkflowTypes, librariesToIgnore);
#elif XRM_MOCKUP_TEST_365
            crm = XrmMockup365.GetInstance(settings);
            var customWorkflowTypes = new List <Type>()
            {
                typeof(CodeActivity)
            };
            crm.RegisterWorkflowCodeActivitiesFromExternalAssemblies(workFlowAssembliesPath, customWorkflowTypes, librariesToIgnore);
#endif

            string pluginAssembliesPath = WebConfigurationManager.AppSettings["CompiledPluginAssembliesPath"];
            crm.RegisterPluginsFromExternalAssemblies(pluginAssembliesPath, settings.BasePluginTypes.ToList(), librariesToIgnore);



            try
            {
                var realDataSettings = new XrmMockupSettings
                {
                    BasePluginTypes           = settings.BasePluginTypes,
                    CodeActivityInstanceTypes = settings.CodeActivityInstanceTypes,
                    EnableProxyTypes          = settings.EnableProxyTypes,
                    IncludeAllWorkflows       = settings.IncludeAllWorkflows,
                    ExceptionFreeRequests     = settings.ExceptionFreeRequests,
                    OnlineEnvironment         = new Env
                    {
                        providerType = AuthenticationProviderType.OnlineFederation,
                        uri          = "https://exampleURL/XRMServices/2011/Organization.svc",
                        username     = "******",
                        password     = "******"
                    }
                };
#if XRM_MOCKUP_TEST_2011
                crmRealData = XrmMockup2011.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2013
                crmRealData = XrmMockup2013.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2015
                crmRealData = XrmMockup2015.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_2016
                crmRealData = XrmMockup2016.GetInstance(realDataSettings);
#elif XRM_MOCKUP_TEST_365
                crmRealData = XrmMockup365.GetInstance(realDataSettings);
#endif
            }
            catch
            {
                // ignore
            }
        }