public void DeploymentImportXmlAssociationsAndNotesTest()
        {
            PrepareTests();
            var types      = new[] { Entities.jmcg_testentity };
            var workFolder = ClearFilesAndData(types);

            var importService = new ImportXmlService(XrmRecordService);

            var createRecords = new List <Entity>();

            foreach (var type in types)
            {
                for (var i = 0; i < 2; i++)
                {
                    createRecords.Add(CreateTestRecord(type, importService));
                }
            }
            //if throws error ensure the test entity allows notes
            XrmService.Associate(Relationships.jmcg_testentity_.jmcg_testentity_jmcg_testentity.Name, Entities.jmcg_testentity, createRecords[0].Id, true, Entities.jmcg_testentity, createRecords[1].Id);
            var aNote = CreateTestRecord(Entities.annotation, new Dictionary <string, object>
            {
                { Fields.annotation_.objectid, createRecords[0].ToEntityReference() },
                { Fields.annotation_.subject, "Test Scripting" },
                { Fields.annotation_.notetext, "Just For Importing Testing" },
            });


            var exportService = new ExportXmlService(XrmRecordService);
            var exportRequest = new ExportXmlRequest
            {
                Folder = new Folder(workFolder),
                RecordTypesToExport = types.Select(t => new ExportRecordType()
                {
                    RecordType = new RecordType(t, t)
                }),
                IncludeNNRelationshipsBetweenEntities = true,
                IncludeNotes = true
            };
            var response = exportService.Execute(exportRequest, new ServiceRequestController(Controller));

            Assert.IsFalse(response.HasError);

            foreach (var type in types)
            {
                DeleteAll(type);
            }

            var application = CreateAndLoadTestApplication <ImportXmlModule>();

            var importRequest = new ImportXmlRequest
            {
                Folder = new Folder(workFolder)
            };

            var importResponse = application.NavigateAndProcessDialog <ImportXmlModule, ImportXmlDialog, ImportXmlResponse>(importRequest);

            Assert.IsFalse(importResponse.HasError);

            var rMetadata = XrmService.GetRelationshipMetadata(Relationships.jmcg_testentity_.jmcg_testentity_jmcg_testentity.Name);

            foreach (var record in createRecords)
            {
                var loaded = Refresh(record);
                if (createRecords[0].Id == loaded.Id)
                {
                    var notes = XrmService.RetrieveAllAndClauses(Entities.annotation, new[]
                    {
                        new ConditionExpression(Fields.annotation_.objectid, ConditionOperator.Equal, loaded.Id)
                    });
                    Assert.AreEqual(1, notes.Count());
                    var associated = XrmService.GetAssociatedIds(rMetadata.SchemaName, rMetadata.Entity1IntersectAttribute, loaded.Id, rMetadata.Entity2IntersectAttribute);
                    Assert.AreEqual(1, associated.Count());
                    Assert.AreEqual(createRecords[1].Id, associated.First());
                }
            }
        }
示例#2
0
        public void RecreatePortalData()
        {
            DeleteAll(Entities.adx_websitelanguage);
            DeleteAll(Entities.adx_webrole);
            DeleteAll(Entities.adx_webpage);
            DeleteAll(Entities.adx_webpageaccesscontrolrule);
            DeleteAll(Entities.adx_entityform);
            DeleteAll(Entities.adx_entityformmetadata);

            var websiteLanguage = CreateTestRecord(Entities.adx_websitelanguage, new Dictionary <string, object>
            {
                { Fields.adx_websitelanguage_.adx_name, "English" }
            });

            var webRole = CreateTestRecord(Entities.adx_webrole, new Dictionary <string, object>
            {
                { Fields.adx_webrole_.adx_name, "TestScriptRole" }
            });

            var webPage = CreateTestRecord(Entities.adx_webpage, new Dictionary <string, object>
            {
                { Fields.adx_webpage_.adx_name, "IScriptWebPage" }
            });
            var childWebPage = CreateTestRecord(Entities.adx_webpage, new Dictionary <string, object>
            {
                { Fields.adx_webpage_.adx_name, "IScriptWebPage" },
                { Fields.adx_webpage_.adx_rootwebpageid, webPage.ToEntityReference() },
                { Fields.adx_webpage_.adx_webpagelanguageid, websiteLanguage.ToEntityReference() }
            });
            var webpageAccessControlRule = CreateTestRecord(Entities.adx_webpageaccesscontrolrule, new Dictionary <string, object>
            {
                { Fields.adx_webpageaccesscontrolrule_.adx_name, "IScriptWebPage" },
                { Fields.adx_webpageaccesscontrolrule_.adx_webpageid, childWebPage.ToEntityReference() },
            });

            XrmService.Associate(Relationships.adx_webrole_.adx_webpageaccesscontrolrule_webrole.Name, Fields.adx_webpageaccesscontrolrule_.adx_webpageaccesscontrolruleid, webpageAccessControlRule.Id, Fields.adx_webrole_.adx_webroleid, webRole.Id);

            var entityForm = CreateTestRecord(Entities.adx_entityform, new Dictionary <string, object>
            {
                { Fields.adx_entityform_.adx_name, "IScriptEntityForm" }
            });

            var entityFormMetadata1 = CreateTestRecord(Entities.adx_entityformmetadata, new Dictionary <string, object>
            {
                { Fields.adx_entityform_.adx_name, null },
                { Fields.adx_entityformmetadata_.adx_entityform, entityForm.ToEntityReference() },
                { Fields.adx_entityformmetadata_.adx_type, new OptionSetValue(OptionSets.EntityFormMetadata.Type.Attribute) },
                { Fields.adx_entityformmetadata_.adx_attributelogicalname, "foo" },
            });

            var entityFormMetadata2 = CreateTestRecord(Entities.adx_entityformmetadata, new Dictionary <string, object>
            {
                { Fields.adx_entityform_.adx_name, null },
                { Fields.adx_entityformmetadata_.adx_entityform, entityForm.ToEntityReference() },
                { Fields.adx_entityformmetadata_.adx_type, new OptionSetValue(OptionSets.EntityFormMetadata.Type.Attribute) },
                { Fields.adx_entityformmetadata_.adx_attributelogicalname, "bar" },
            });

            var entityFormMetadata3 = CreateTestRecord(Entities.adx_entityformmetadata, new Dictionary <string, object>
            {
                { Fields.adx_entityform_.adx_name, null },
                { Fields.adx_entityformmetadata_.adx_entityform, entityForm.ToEntityReference() },
                { Fields.adx_entityformmetadata_.adx_type, new OptionSetValue(OptionSets.EntityFormMetadata.Type.Notes) }
            });
        }
        public void InstanceComparerModuleTest()
        {
            //this just compares an instance against itself
            //rather than actually comparing 2 instances
            DeleteAll(Entities.jmcg_testentity);
            DeleteAll(Entities.account);
            var t1 = CreateTestRecord(Entities.jmcg_testentity, new Dictionary <string, object>
            {
                { Fields.jmcg_testentity_.jmcg_name, "Blah 1" }
            });
            var a1 = CreateTestRecord(Entities.account, new Dictionary <string, object>
            {
                { Fields.account_.name, "Blah 1" }
            });

            XrmService.Associate(Relationships.jmcg_testentity_.jmcg_testentity_account.Name, Fields.jmcg_testentity_.jmcg_testentityid, t1.Id, Fields.account_.accountid, a1.Id);

            RecreatePortalData();

            var request = new InstanceComparerRequest();

            request.ConnectionOne   = GetSavedXrmRecordConfiguration();
            request.ConnectionTwo   = GetSavedXrmRecordConfiguration();
            request.DataComparisons = new[]
            {
                new InstanceComparerRequest.InstanceCompareDataCompare()
                {
                    RecordType = new RecordType(Entities.jmcg_testentity, Entities.jmcg_testentity)
                },
                new InstanceComparerRequest.InstanceCompareDataCompare()
                {
                    RecordType = new RecordType(Entities.account, Entities.account)
                },
                new InstanceComparerRequest.InstanceCompareDataCompare()
                {
                    RecordType = new RecordType(Entities.adx_entityform, Entities.account)
                },
                new InstanceComparerRequest.InstanceCompareDataCompare()
                {
                    RecordType = new RecordType(Entities.adx_entityformmetadata, Entities.account)
                },
                new InstanceComparerRequest.InstanceCompareDataCompare()
                {
                    RecordType = new RecordType(Entities.adx_webfile, Entities.account)
                },
                new InstanceComparerRequest.InstanceCompareDataCompare()
                {
                    RecordType = new RecordType(Entities.adx_webpage, Entities.account)
                },
                new InstanceComparerRequest.InstanceCompareDataCompare()
                {
                    RecordType = new RecordType(Entities.adx_webpageaccesscontrolrule, Entities.account)
                },
                new InstanceComparerRequest.InstanceCompareDataCompare()
                {
                    RecordType = new RecordType(Entities.adx_webrole, Entities.account)
                },
                new InstanceComparerRequest.InstanceCompareDataCompare()
                {
                    RecordType = new RecordType(Entities.adx_websitelanguage, Entities.account)
                },
            };
            foreach (var prop in request.GetType().GetProperties())
            {
                if (prop.PropertyType == typeof(bool))
                {
                    request.SetPropertyValue(prop.Name, true);
                }
            }
            request.DisplaySavedSettingFields = false;

            var application = CreateAndLoadTestApplication <InstanceComparerModule>();
            var response    = application.NavigateAndProcessDialog <InstanceComparerModule, InstanceComparerDialog, InstanceComparerResponse>(request);

            if (response.HasError)
            {
                if (response.Exception != null)
                {
                    Assert.Fail(response.Exception.XrmDisplayString());
                }
                else
                {
                    Assert.Fail(response.GetResponseItemsWithError().First().ErrorDetails);
                }
            }
            Assert.IsFalse(response.AreDifferences);
        }
示例#4
0
        private void CreateWebsiteRecords(Entity website)
        {
            var webFile = CreateTestRecord(Entities.adx_webfile, new Dictionary <string, object>
            {
                { Fields.adx_webfile_.adx_name, "Fake Web File.css" },
                { Fields.adx_webfile_.adx_websiteid, website.ToEntityReference() }
            });

            var file                = Path.Combine(GetSolutionRootFolder().FullName, "SolutionItems", "TestFiles", "WEB FILE", "TESTDEPLOYINTO.css");
            var contentBytes        = File.ReadAllBytes(file);
            var contentBase64String = Convert.ToBase64String(contentBytes);
            var webFileAttachment   = CreateTestRecord(Entities.annotation, new Dictionary <string, object>
            {
                { Fields.annotation_.subject, "Fake Web File.css" },
                { Fields.annotation_.objectid, webFile.ToEntityReference() },
                { Fields.annotation_.documentbody, contentBase64String },
            });

            var webFile2 = CreateTestRecord(Entities.adx_webfile, new Dictionary <string, object>
            {
                { Fields.adx_webfile_.adx_name, "Fake Web File 2.css" },
                { Fields.adx_webfile_.adx_websiteid, website.ToEntityReference() }
            });

            var webTemplate1 = CreateTestRecord(Entities.adx_webtemplate, new Dictionary <string, object>
            {
                { Fields.adx_webtemplate_.adx_name, "Fake Web Template 1" },
                { Fields.adx_webtemplate_.adx_websiteid, website.ToEntityReference() },
                { Fields.adx_webtemplate_.adx_source, "<html><body><div>Web Template 1</div></body></html>" }
            });

            var webTemplate2 = CreateTestRecord(Entities.adx_webtemplate, new Dictionary <string, object>
            {
                { Fields.adx_webtemplate_.adx_name, "Fake Web Template 2" },
                { Fields.adx_webtemplate_.adx_websiteid, website.ToEntityReference() },
                { Fields.adx_webtemplate_.adx_source, "<html><body><div>Web Template 2</div></body></html>" }
            });

            var webTemplate3 = CreateTestRecord(Entities.adx_webtemplate, new Dictionary <string, object>
            {
                { Fields.adx_webtemplate_.adx_name, "Fake Web Template 3" },
                { Fields.adx_webtemplate_.adx_websiteid, website.ToEntityReference() },
            });

            var weblinkSet1 = CreateTestRecord(Entities.adx_weblinkset, new Dictionary <string, object>
            {
                { Fields.adx_weblinkset_.adx_name, "Fake Link Set 1" }
            });

            var weblinkSet2 = CreateTestRecord(Entities.adx_weblinkset, new Dictionary <string, object>
            {
                { Fields.adx_weblinkset_.adx_name, "Fake Link Set 2" }
            });

            var weblink1a = CreateTestRecord(Entities.adx_weblink, new Dictionary <string, object>
            {
                { Fields.adx_weblink_.adx_name, "Fake Link a" },
                { Fields.adx_weblink_.adx_weblinksetid, weblinkSet1.ToEntityReference() }
            });

            var weblink1b = CreateTestRecord(Entities.adx_weblink, new Dictionary <string, object>
            {
                { Fields.adx_weblink_.adx_name, "Fake Link b" },
                { Fields.adx_weblink_.adx_weblinksetid, weblinkSet1.ToEntityReference() }
            });

            var weblink2b = CreateTestRecord(Entities.adx_weblink, new Dictionary <string, object>
            {
                { Fields.adx_weblink_.adx_name, "Fake Link b" },
                { Fields.adx_weblink_.adx_weblinksetid, weblinkSet2.ToEntityReference() }
            });

            var weblink2c = CreateTestRecord(Entities.adx_weblink, new Dictionary <string, object>
            {
                { Fields.adx_weblink_.adx_name, "Fake Link c" },
                { Fields.adx_weblink_.adx_weblinksetid, weblinkSet2.ToEntityReference() }
            });

            var weblink2bc = CreateTestRecord(Entities.adx_weblink, new Dictionary <string, object>
            {
                { Fields.adx_weblink_.adx_name, "Fake Link bc" },
                { Fields.adx_weblink_.adx_parentweblinkid, weblink2c.ToEntityReference() }
            });

            var websiteLanguage = CreateTestRecord(Entities.adx_websitelanguage, new Dictionary <string, object>
            {
                { Fields.adx_websitelanguage_.adx_name, "English" }
            });

            var webRole = CreateTestRecord(Entities.adx_webrole, new Dictionary <string, object>
            {
                { Fields.adx_webrole_.adx_name, "TestScriptRole" }
            });

            var webPage = CreateTestRecord(Entities.adx_webpage, new Dictionary <string, object>
            {
                { Fields.adx_webpage_.adx_name, "IScriptWebPage" },
                { Fields.adx_webpage_.adx_websiteid, website.ToEntityReference() },
                { Fields.adx_webpage_.adx_copy, "<div>Page Copy Parent</div>" }
            });
            var childWebPage = CreateTestRecord(Entities.adx_webpage, new Dictionary <string, object>
            {
                { Fields.adx_webpage_.adx_name, "IScriptWebPage" },
                { Fields.adx_webpage_.adx_websiteid, website.ToEntityReference() },
                { Fields.adx_webpage_.adx_rootwebpageid, webPage.ToEntityReference() },
                { Fields.adx_webpage_.adx_webpagelanguageid, websiteLanguage.ToEntityReference() },
                { Fields.adx_webpage_.adx_copy, "<div>Page Copy</div>" },
                { Fields.adx_webpage_.adx_customcss, ".class { color : white }" },
                { Fields.adx_webpage_.adx_customjavascript, "var blah = 'javascript'" },
            });
            var webpageAccessControlRule = CreateTestRecord(Entities.adx_webpageaccesscontrolrule, new Dictionary <string, object>
            {
                { Fields.adx_webpageaccesscontrolrule_.adx_name, "IScriptWebPage" },
                { Fields.adx_webpageaccesscontrolrule_.adx_webpageid, childWebPage.ToEntityReference() },
            });

            var entityForm = CreateTestRecord(Entities.adx_entityform, new Dictionary <string, object>
            {
                { Fields.adx_entityform_.adx_name, "IScriptEntityForm" },
                { Fields.adx_entityform_.adx_websiteid, website.ToEntityReference() },
                { Fields.adx_entityform_.adx_registerstartupscript, "var blah = 'entityform'" }
            });

            var entityFormMetadata1 = CreateTestRecord(Entities.adx_entityformmetadata, new Dictionary <string, object>
            {
                { Fields.adx_entityform_.adx_name, null },
                { Fields.adx_entityformmetadata_.adx_entityform, entityForm.ToEntityReference() },
                { Fields.adx_entityformmetadata_.adx_type, new OptionSetValue(OptionSets.EntityFormMetadata.Type.Attribute) },
                { Fields.adx_entityformmetadata_.adx_attributelogicalname, "foo" },
            });

            var entityFormMetadata2 = CreateTestRecord(Entities.adx_entityformmetadata, new Dictionary <string, object>
            {
                { Fields.adx_entityform_.adx_name, null },
                { Fields.adx_entityformmetadata_.adx_entityform, entityForm.ToEntityReference() },
                { Fields.adx_entityformmetadata_.adx_type, new OptionSetValue(OptionSets.EntityFormMetadata.Type.Attribute) },
                { Fields.adx_entityformmetadata_.adx_attributelogicalname, "bar" },
            });

            var entityFormMetadata3 = CreateTestRecord(Entities.adx_entityformmetadata, new Dictionary <string, object>
            {
                { Fields.adx_entityform_.adx_name, null },
                { Fields.adx_entityformmetadata_.adx_entityform, entityForm.ToEntityReference() },
                { Fields.adx_entityformmetadata_.adx_type, new OptionSetValue(OptionSets.EntityFormMetadata.Type.Notes) }
            });

            var entityList = CreateTestRecord(Entities.adx_entitylist, new Dictionary <string, object>
            {
                { Fields.adx_entitylist_.adx_name, "IScriptEntityList" },
                { Fields.adx_entitylist_.adx_websiteid, website.ToEntityReference() },
                { Fields.adx_entitylist_.adx_registerstartupscript, "var blah = 'entityform'" }
            });

            var webForm = CreateTestRecord(Entities.adx_webform, new Dictionary <string, object>
            {
                { Fields.adx_webform_.adx_name, "IScriptWebForm" },
                { Fields.adx_webform_.adx_websiteid, website.ToEntityReference() },
            });

            var webFormStep = CreateTestRecord(Entities.adx_webformstep, new Dictionary <string, object>
            {
                { Fields.adx_webformstep_.adx_name, "IScriptWebFormStep1" },
                { Fields.adx_webformstep_.adx_webform, webForm.ToEntityReference() },
                { Fields.adx_webformstep_.adx_registerstartupscript, "var blah = 'web form step'" }
            });

            var webFormStep2 = CreateTestRecord(Entities.adx_webformstep, new Dictionary <string, object>
            {
                { Fields.adx_webformstep_.adx_name, "IScriptWebFormStep2" },
                { Fields.adx_webformstep_.adx_webform, webForm.ToEntityReference() },
                { Fields.adx_webformstep_.adx_registerstartupscript, "var blah = 'web form step 2'" }
            });

            var webFormMetadata1 = CreateTestRecord(Entities.adx_webformmetadata, new Dictionary <string, object>
            {
                { Fields.adx_webformmetadata_.adx_webformstep, webFormStep.ToEntityReference() },
                { Fields.adx_webformmetadata_.adx_type, new OptionSetValue(OptionSets.WebFormMetadata.Type.Attribute) },
                { Fields.adx_webformmetadata_.adx_attributelogicalname, "foo" },
            });

            var webFormMetadata2 = CreateTestRecord(Entities.adx_webformmetadata, new Dictionary <string, object>
            {
                { Fields.adx_webformmetadata_.adx_webformstep, webFormStep.ToEntityReference() },
                { Fields.adx_webformmetadata_.adx_type, new OptionSetValue(OptionSets.WebFormMetadata.Type.Attribute) },
                { Fields.adx_webformmetadata_.adx_attributelogicalname, "bar" },
            });

            var webFormMetadata3 = CreateTestRecord(Entities.adx_webformmetadata, new Dictionary <string, object>
            {
                { Fields.adx_webformmetadata_.adx_attributelogicalname, null },
                { Fields.adx_webformmetadata_.adx_webformstep, webFormStep.ToEntityReference() },
                { Fields.adx_webformmetadata_.adx_type, new OptionSetValue(OptionSets.WebFormMetadata.Type.Notes) }
            });

            var webFormMetadata4 = CreateTestRecord(Entities.adx_webformmetadata, new Dictionary <string, object>
            {
                { Fields.adx_webformmetadata_.adx_attributelogicalname, null },
                { Fields.adx_webformmetadata_.adx_webformstep, webFormStep2.ToEntityReference() },
                { Fields.adx_webformmetadata_.adx_type, new OptionSetValue(OptionSets.WebFormMetadata.Type.Notes) }
            });

            var contentSnippet = CreateTestRecord(Entities.adx_contentsnippet, new Dictionary <string, object>
            {
                { Fields.adx_contentsnippet_.adx_name, "IContentSnippet" },
            });

            var entityPermission = CreateTestRecord(Entities.adx_entitypermission, new Dictionary <string, object>
            {
                { Fields.adx_entitypermission_.adx_name, "IEntityPermission" },
            });

            var pageTemplate = CreateTestRecord(Entities.adx_pagetemplate, new Dictionary <string, object>
            {
                { Fields.adx_pagetemplate_.adx_name, "IPageTemplate" },
            });

            var publishingState = CreateTestRecord(Entities.adx_publishingstate, new Dictionary <string, object>
            {
                { Fields.adx_publishingstate_.adx_name, "IPublishingState" },
            });

            var siteSetting = CreateTestRecord(Entities.adx_sitesetting, new Dictionary <string, object>
            {
                { Fields.adx_sitesetting_.adx_name, "ISiteSetting" },
            });

            var sitemarker = CreateTestRecord(Entities.adx_sitemarker, new Dictionary <string, object>
            {
                { Fields.adx_sitemarker_.adx_name, "ISiteMarker" },
            });

            var contentAccessLevel = CreateTestRecord(Entities.adx_contentaccesslevel, new Dictionary <string, object>
            {
                { Fields.adx_contentaccesslevel_.adx_name, "IContentAccessLevel" },
            });

            XrmService.Associate(Relationships.adx_contentaccesslevel_.adx_WebRoleContentAccessLevel.Name, Fields.adx_contentaccesslevel_.adx_contentaccesslevelid, contentAccessLevel.Id, Fields.adx_webrole_.adx_webroleid, webRole.Id);
            XrmService.Associate(Relationships.adx_entitypermission_.adx_entitypermission_webrole.Name, Fields.adx_entitypermission_.adx_entitypermissionid, entityPermission.Id, Fields.adx_webrole_.adx_webroleid, webRole.Id);
            XrmService.Associate(Relationships.adx_publishingstate_.adx_accesscontrolrule_publishingstate.Name, Fields.adx_publishingstate_.adx_publishingstateid, publishingState.Id, Fields.adx_webpageaccesscontrolrule_.adx_webpageaccesscontrolruleid, webpageAccessControlRule.Id);
            XrmService.Associate(Relationships.adx_webpageaccesscontrolrule_.adx_webpageaccesscontrolrule_webrole.Name, Fields.adx_webpageaccesscontrolrule_.adx_webpageaccesscontrolruleid, webpageAccessControlRule.Id, Fields.adx_webrole_.adx_webroleid, webRole.Id);
        }