public void MissingMetadata_Throws()
        {
            var fakedContext = new XrmFakedContext();

            fakedContext.InitializeMetadata(typeof(CrmEarlyBound.CrmServiceContext).Assembly);
            fakedContext.Initialize(SupportMethods.GetCustomerTypeEntity());
            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var entityMetadata = fakedContext.GetEntityMetadataByName(String.Empty);
                var response       = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            IOrganizationService fakedService = new Client.Services.OrganizationService(new Client.CrmConnection()); // fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            var ex = Assert.ThrowsException <Exception>(() => DataBuilder.AppendData(SupportMethods.GetCustomerTypeFetch()));
        }
Ejemplo n.º 2
0
        public static Dictionary <String, Object>[] GetStringTypePowerShellObjects()
        {
            var entity1 = SupportMethods.GetStringTypePowerShellObject();
            var entity2 = SupportMethods.GetStringTypePowerShellObject();

            return(new Dictionary <String, Object>[] { entity1, entity2 });
        }
        public void UniqueidentifierType()
        {
            // UniqueidentifierType stageid                            knowledgearticle
            var fakedContext = new XrmFakedContext();

            fakedContext.InitializeMetadata(typeof(CrmEarlyBound.CrmServiceContext).Assembly);
            fakedContext.Initialize(SupportMethods.GetUniqueIdentifierTypeEntity());
            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var entityMetadata         = fakedContext.GetEntityMetadataByName(SupportMethods.KnowledgeArticleLogicalName);
                entityMetadata.DisplayName = new Label(SupportMethods.KnowledgeArticleDisplayName, 1033);
                entityMetadata.Attributes.First(a => a.LogicalName == "stageid").SetSealedPropertyValue("AttributeType", Sdk.Metadata.AttributeTypeCode.Uniqueidentifier);

                var response = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetUniqueIdentifierTypeFetch());
            Assert.AreEqual(
                DataBuilder.BuildDataXML().InnerXml,
                SupportMethods.GetUniqueIdentifierTypeExpectedData());
        }
Ejemplo n.º 4
0
        public void AppendDataUsingDictionariesLikePowerShell_Works()
        {
            // StringType           description                        knowledgearticle
            var fakedContext = new XrmFakedContext();

            fakedContext.InitializeMetadata(typeof(CrmEarlyBound.CrmServiceContext).Assembly);
            fakedContext.Initialize(SupportMethods.GetStringTypeEntity());
            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var entityMetadata         = fakedContext.GetEntityMetadataByName(SupportMethods.KnowledgeArticleLogicalName);
                entityMetadata.DisplayName = new Label(SupportMethods.KnowledgeArticleDisplayName, 1033);
                var response = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.KnowledgeArticleLogicalName, SupportMethods.GetStringTypePowerShellObjects());
            Assert.AreEqual(
                DataBuilder.BuildDataXML().InnerXml,
                SupportMethods.GetStringTypeExpectedData());
        }
Ejemplo n.º 5
0
        public void ContentType_Builds()
        {
            XrmFakedContext context     = new XrmFakedContext();
            DataBuilder     DataBuilder = new DataBuilder(context.GetOrganizationService());

            Assert.AreEqual(
                DataBuilder.BuildContentTypesXML().InnerXml,
                SupportMethods.LoadXmlFile(@"../../lib/Configurations/[Content_Types].xml"));
        }
        public void MemoType()
        {
            DataBuilder db = new DataBuilder();

            db.AppendData(SupportMethods.GetMemoTypeExpectedData(), SupportMethods.GetMemoTypeExpectedSchema());

            Assert.AreEqual(
                db.BuildSchemaXML().InnerXml,
                SupportMethods.GetMemoTypeExpectedSchema());
        }
Ejemplo n.º 7
0
        public void AllEntities_SomePluginsDisabled_MixedIdentifiers_DataImported()
        {
            XrmFakedContext fakedContext = new XrmFakedContext();
            DataBuilder     db           = new DataBuilder();

            db.AppendData(SupportMethods.GetAllEntities_SomePluginsDisabled_MixedIdentifiersExpectedData(), SupportMethods.GetAllEntities_SomePluginsDisabled_MixedIdentifiersExpectedSchema());

            Assert.AreEqual(
                db.BuildDataXML().InnerXml,
                SupportMethods.GetAllEntities_SomePluginsDisabled_MixedIdentifiersExpectedData());
        }
        public void LookupType()
        {
            XrmFakedContext fakedContext = new XrmFakedContext();
            DataBuilder     db           = new DataBuilder();

            db.AppendData(SupportMethods.GetLookupTypeExpectedData(), SupportMethods.GetLookupTypeExpectedSchema());

            Assert.AreEqual(
                db.BuildDataXML().InnerXml,
                SupportMethods.GetLookupTypeExpectedData());
        }
Ejemplo n.º 9
0
        public void RemoveDataXMLWithNonExistentField_RemovesNothing()
        {
            DataBuilder db = new DataBuilder();

            db.AppendData(SupportMethods.GetIntegerTypeExpectedData(), SupportMethods.GetIntegerTypeExpectedSchema());

            db.RemoveData(SupportMethods.GetLookupTypeExpectedData(), SupportMethods.GetLookupTypeExpectedSchema());

            Assert.AreEqual(
                db.BuildDataXML().InnerXml,
                SupportMethods.GetIntegerTypeExpectedData());
        }
        public void BrokenConnection_Throws()
        {
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.IncidentLogicalName,
                SupportMethods.IncidentDisplayName,
                SupportMethods.GetCustomerTypeEntity());

            IOrganizationService fakedService = new Client.Services.OrganizationService(new Client.CrmConnection()); // fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            var ex = Assert.ThrowsException <Exception>(() => DataBuilder.AppendData(SupportMethods.GetCustomerTypeFetch()));
        }
Ejemplo n.º 11
0
        public void BooleanRemove()
        {
            DataBuilder db = new DataBuilder();

            db.AppendData(SupportMethods.GetIntegerTypeExpectedData(), SupportMethods.GetIntegerTypeExpectedSchema());
            db.AppendData(SupportMethods.GetBooleanTypeExpectedData(), SupportMethods.GetBooleanTypeExpectedSchema());

            db.RemoveData(SupportMethods.GetBooleanTypeExpectedData(), SupportMethods.GetBooleanTypeExpectedSchema());

            Assert.AreEqual(
                db.BuildDataXML().InnerXml,
                SupportMethods.GetIntegerTypeExpectedData());
        }
Ejemplo n.º 12
0
        public void RemoveDataXMLWithPartialM2MRelationship_RemovesPartOfRelationship()
        {
            DataBuilder db = new DataBuilder();

            db.AppendData(SupportMethods.Getm2mRelationshipTypeExpectedData(), SupportMethods.Getm2mRelationshipTypeExpectedSchema());
            db.AppendData(SupportMethods.Getm2mRelationshipTypeExpectedData2(), SupportMethods.Getm2mRelationshipTypeExpectedSchema());

            db.RemoveData(SupportMethods.Getm2mRelationshipTypeExpectedData2(), SupportMethods.Getm2mRelationshipTypeExpectedSchema());

            Assert.AreEqual(
                db.BuildDataXML().InnerXml,
                SupportMethods.Getm2mRelationshipTypeExpectedData());
        }
Ejemplo n.º 13
0
        public void RemoveEntityWithSingleField_RemovesField()
        {
            DataBuilder db = new DataBuilder();

            db.AppendData(SupportMethods.GetIntegerTypeExpectedData(), SupportMethods.GetIntegerTypeExpectedSchema());
            db.AppendData(SupportMethods.GetLookupTypeExpectedData(), SupportMethods.GetLookupTypeExpectedSchema());

            db.RemoveData(SupportMethods.GetLookupTypeEntity());

            Assert.AreEqual(
                db.BuildDataXML().InnerXml,
                SupportMethods.GetIntegerTypeExpectedData());
        }
        public void NoM2MData_ReturnsValidSchemaXML()
        {
            var fakedContext = new XrmFakedContext();

            fakedContext.InitializeMetadata(typeof(CrmEarlyBound.CrmServiceContext).Assembly);

            fakedContext.Initialize(SupportMethods.Getm2mRelationshipTypeEntities());

            fakedContext.AddRelationship("systemuserroles_association", new XrmFakedRelationship
            {
                IntersectEntity    = "systemuserroles",
                Entity1LogicalName = "systemuser",
                Entity1Attribute   = "systemuserid",
                Entity2LogicalName = "role",
                Entity2Attribute   = "roleid"
            });

            var AssociateRequest = SupportMethods.Getm2mRelationshipTypeAssociateRequest();
            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            fakedService.Execute(AssociateRequest);

            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var entityMetadata = fakedContext.GetEntityMetadataByName(SupportMethods.UserLogicalName);

                entityMetadata.DisplayName = new Label(SupportMethods.UserDisplayName, 1033);
                entityMetadata.SetSealedPropertyValue("PrimaryNameAttribute", "fullname");
                entityMetadata.Attributes.First(a => a.LogicalName == "systemuserid").SetSealedPropertyValue("DisplayName", new Label("User", 1033));
                entityMetadata.ManyToManyRelationships.First(m => m.SchemaName == "systemuserroles_association").SetSealedPropertyValue("IntersectEntityName", "systemuserroles");
                entityMetadata.ManyToManyRelationships.First(m => m.SchemaName == "systemuserroles_association").SetSealedPropertyValue("Entity2LogicalName", "role");
                entityMetadata.ManyToManyRelationships.First(m => m.SchemaName == "systemuserroles_association").SetSealedPropertyValue("Entity2IntersectAttribute", "roleid");

                var response = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData("<fetch><entity name='systemuser'><attribute name='systemuserid'/><link-entity name='systemuserroles' from='systemuserid' to='systemuserid' intersect='true'><link-entity name='role' from='roleid' to='roleid'/><attribute name='roleid'/></link-entity><filter><condition attribute='systemuserid' operator='eq' value='00e7b0b9-1ace-e711-a970-000d3a192315'/></filter></entity></fetch>");

            Assert.AreEqual(
                DataBuilder.BuildSchemaXML().InnerXml,
                "<entities />");
        }
        public void ReflexiveM2MRelationship_Schema()
        {
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.AgentScriptActionLogicalName,
                SupportMethods.AgentScriptActionDisplayName,
                SupportMethods.Getm2mReflexiveRelationshipTypeEntities());

            fakedContext.AddRelationship("msdyusd_subactioncalls", new XrmFakedRelationship
            {
                IntersectEntity    = "msdyusd_subactioncalls",
                Entity1LogicalName = "msdyusd_agentscriptaction",
                Entity1Attribute   = "msdyusd_agentscriptactionidone",
                Entity2LogicalName = "msdyusd_agentscriptaction",
                Entity2Attribute   = "msdyusd_agentscriptactionidtwo"
            });

            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var entityMetadata = fakedContext.GetEntityMetadataByName(SupportMethods.AgentScriptActionLogicalName);

                entityMetadata.DisplayName = new Label(SupportMethods.AgentScriptActionDisplayName, 1033);
                entityMetadata.SetSealedPropertyValue("PrimaryNameAttribute", "msdyusd_name");
                entityMetadata.Attributes.First(a => a.LogicalName == "msdyusd_agentscriptactionid").SetSealedPropertyValue("DisplayName", new Label("Agent Script Action", 1033));
                entityMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("IntersectEntityName", "msdyusd_subactioncalls");
                entityMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("Entity1LogicalName", "msdyusd_agentscriptaction");
                entityMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("Entity2LogicalName", "msdyusd_agentscriptaction");
                entityMetadata.ManyToManyRelationships.First(m => m.SchemaName == "msdyusd_subactioncalls").SetSealedPropertyValue("Entity2IntersectAttribute", "msdyusd_agentscriptactionidtwo");

                var response = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            SupportMethods.Getm2mReflexiveRelationshipTypeAssociateRequests().ToList <AssociateRequest>().ForEach(r => fakedService.Execute(r));


            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.Getm2mReflexiveRelationshipTypeFetch());

            Assert.AreEqual(DataBuilder.BuildSchemaXML().InnerXml, SupportMethods.Getm2mReflexiveRelationshipTypeExpectedSchema());
        }
Ejemplo n.º 16
0
        public void BooleanType()
        {
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.ThemeLogicalName,
                SupportMethods.ThemeDisplayName,
                SupportMethods.GetBooleanTypeEntity());
            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetBooleanTypeFetch());
            Assert.AreEqual(
                DataBuilder.BuildDataXML().InnerXml,
                SupportMethods.GetBooleanTypeExpectedData());
        }
        public void ReflexiveRelationship_Data()
        {
            // LookupType           previousarticlecontentid           knowledgearticle
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.KnowledgeArticleLogicalName,
                SupportMethods.KnowledgeArticleDisplayName,
                SupportMethods.GetLookupTypeEntity());
            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetLookupTypeFetch());

            Assert.IsTrue(DataBuilder.BuildDataXML().SelectSingleNode("entities/entity[@name='knowledgearticle']/records/record[@id='" + ((EntityReference)SupportMethods.GetLookupTypeEntity()["previousarticlecontentid"]).Id.ToString() + "']") != null);
        }
Ejemplo n.º 18
0
        public void DoubleType()
        {
            // DoubleType           msdyn_quantity                     msdyn_purchaseorderproduct
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.PurchaseOrderProductLogicalName,
                SupportMethods.PurchaseOrderProductDisplayName,
                SupportMethods.GetDoubleTypeEntity());
            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetDoubleTypeFetch());
            Assert.AreEqual(
                DataBuilder.BuildDataXML().InnerXml,
                SupportMethods.GetDoubleTypeExpectedData());
        }
        public void NoData_ReturnsValidSchemaXML()
        {
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.ThemeLogicalName,
                SupportMethods.ThemeDisplayName,
                SupportMethods.GetBooleanTypeEntity());
            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData("<fetch><entity name='systemuser'></entity></fetch>");

            Assert.AreEqual(
                DataBuilder.BuildSchemaXML().InnerXml,
                "<entities />");
        }
Ejemplo n.º 20
0
        public void SingleEntity_TenRecords_WithCountAsOne_ReturnsTen()
        {
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.ThemeLogicalName,
                SupportMethods.ThemeDisplayName,
                SupportMethods.GetSingleEntity_TenRowsEntity().ToArray());
            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetBooleanTypeFetch_CountIsOne());

            var innerXml = DataBuilder.BuildDataXML();

            Assert.IsTrue(innerXml.SelectSingleNode("//entities/entity/records").ChildNodes.Count == 10);
        }
Ejemplo n.º 21
0
        public void DateTimeType()
        {
            // DateTimeType         publishon                          knowledgearticle
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.KnowledgeArticleLogicalName,
                SupportMethods.KnowledgeArticleDisplayName,
                SupportMethods.GetDateTimeTypeEntity());
            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetDateTimeTypeFetch());
            Assert.AreEqual(
                DataBuilder.BuildDataXML().InnerXml,
                SupportMethods.GetDateTimeTypeExpectedData());
        }
Ejemplo n.º 22
0
        public void DecimalType()
        {
            // DecimalType          msdyn_hours                        msdyn_resourcerequirementdetail
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.ResourceRequirementDetailLogicalName,
                SupportMethods.ResourceRequirementDetailDisplayName,
                SupportMethods.GetDecimalTypeEntity());
            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetDecimalTypeFetch());
            Assert.AreEqual(
                DataBuilder.BuildDataXML().InnerXml,
                SupportMethods.GetDecimalTypeExpectedData());
        }
Ejemplo n.º 23
0
        public void CustomerType()
        {
            // CustomerType         customerid                         incident
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.IncidentLogicalName,
                SupportMethods.IncidentDisplayName,
                SupportMethods.GetCustomerTypeEntity());
            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetCustomerTypeFetch());
            Assert.AreEqual(
                DataBuilder.BuildDataXML().InnerXml,
                SupportMethods.GetCustomerTypeExpectedData());
        }
Ejemplo n.º 24
0
        public void PartyListType()
        {
            // PartyListType        customers                          msdyn_approval
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.ApprovalLogicalName,
                SupportMethods.ApprovalDisplayName,
                SupportMethods.GetPartyListTypeEntity());

            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var logicalName = ((RetrieveEntityRequest)req).LogicalName;
                var displayName = String.Empty;
                switch (logicalName)
                {
                case SupportMethods.ApprovalLogicalName:
                    displayName = SupportMethods.ApprovalDisplayName;
                    break;

                case SupportMethods.ActivityPartyLogicalName:
                    displayName = SupportMethods.ActivityPartyDisplayName;
                    break;

                default:
                    throw new NotImplementedException();
                }
                var entityMetadata = fakedContext.GetEntityMetadataByName(logicalName);

                entityMetadata.DisplayName = new Label(displayName, 1033);
                var response = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetPartyListTypeFetch());
            Assert.AreEqual(
                DataBuilder.BuildDataXML().InnerXml,
                SupportMethods.GetPartyListTypeExpectedData());
        }
Ejemplo n.º 25
0
        public void PartyListType()
        {
            // PartyListType        customers                          msdyn_approval
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.ApprovalLogicalName,
                SupportMethods.ApprovalDisplayName,
                SupportMethods.GetPartyListTypeEntity());

            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var logicalName    = ((RetrieveEntityRequest)req).LogicalName;
                var entityMetadata = fakedContext.GetEntityMetadataByName(logicalName);

                entityMetadata.DisplayName = new Label("Approval", 1033);
                entityMetadata.SetSealedPropertyValue("PrimaryNameAttribute", "subject");

                if (entityMetadata.LogicalName == SupportMethods.ApprovalLogicalName)
                {
                    entityMetadata.Attributes.First(a => a.LogicalName == "customers").SetSealedPropertyValue("DisplayName", new Label("Customers", 1033));
                    entityMetadata.Attributes.First(a => a.LogicalName == "customers").SetSealedPropertyValue("AttributeType", Sdk.Metadata.AttributeTypeCode.PartyList);
                    entityMetadata.Attributes.First(a => a.LogicalName == "activityid").SetSealedPropertyValue("DisplayName", new Label("Approval", 1033));
                }

                var response = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetPartyListTypeFetch());
            Assert.AreEqual(
                DataBuilder.BuildSchemaXML().InnerXml,
                SupportMethods.GetPartyListTypeExpectedSchema());
        }
        public void UnsupportedTypeCode_SkipsField()
        {
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.IncidentLogicalName,
                SupportMethods.IncidentDisplayName,
                SupportMethods.GetCustomerTypeEntity());

            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var entityMetadata         = fakedContext.GetEntityMetadataByName(SupportMethods.IncidentLogicalName);
                entityMetadata.DisplayName = new Label(SupportMethods.IncidentDisplayName, 1033);
                entityMetadata.SetSealedPropertyValue("PrimaryNameAttribute", "title");

                entityMetadata.Attributes.First(a => a.LogicalName == "customerid").SetSealedPropertyValue("DisplayName", new Label("Customer", 1033));
                entityMetadata.Attributes.First(a => a.LogicalName == "customerid").SetSealedPropertyValue("AttributeType", Sdk.Metadata.AttributeTypeCode.CalendarRules);
                entityMetadata.Attributes.First(a => a.LogicalName == "customerid").SetSealedPropertyValue("Targets", new String[] { "account", "contact" });
                entityMetadata.Attributes.First(a => a.LogicalName == "incidentid").SetSealedPropertyValue("DisplayName", new Label("Case", 1033));

                var response = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetCustomerTypeFetch());

            var XML = DataBuilder.BuildDataXML();

            Assert.AreEqual(1, XML.SelectSingleNode("//records/record").ChildNodes.Count);
            Assert.AreEqual("incidentid", XML.SelectSingleNode("//records/record/field/@name").Value);
        }
Ejemplo n.º 27
0
        public void BooleanType()
        {
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.ThemeLogicalName,
                SupportMethods.ThemeDisplayName,
                SupportMethods.GetBooleanTypeEntity());

            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var entityMetadata         = fakedContext.GetEntityMetadataByName(SupportMethods.ThemeLogicalName);
                entityMetadata.DisplayName = new Label(SupportMethods.ThemeDisplayName, 1033);
                entityMetadata.SetSealedPropertyValue("PrimaryNameAttribute", "name");

                entityMetadata.Attributes.First(a => a.LogicalName == "isdefaulttheme").SetSealedPropertyValue("DisplayName", new Label("Default Theme", 1033));
                entityMetadata.Attributes.First(a => a.LogicalName == "themeid").SetSealedPropertyValue("DisplayName", new Label("Theme", 1033));

                var response = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetBooleanTypeFetch_TopIsOne());

            String DataBuilderXML = DataBuilder.BuildSchemaXML().InnerXml;
            String RealXml        = SupportMethods.GetBooleanTypeExpectedSchema();

            Assert.AreEqual(
                DataBuilder.BuildSchemaXML().InnerXml,
                SupportMethods.GetBooleanTypeExpectedSchema());
        }
Ejemplo n.º 28
0
        public void MultiValueIdentifierSchema()
        {
            var fakedContext = new XrmFakedContext();

            fakedContext.InitializeMetadata(typeof(CrmEarlyBound.CrmServiceContext).Assembly);
            fakedContext.Initialize(SupportMethods.GetMultiValueIdentifierEntity());
            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var entityMetadata         = fakedContext.GetEntityMetadataByName(SupportMethods.ContactLogicalName);
                entityMetadata.DisplayName = new Label(SupportMethods.ContactDisplayName, 1033);
                entityMetadata.SetSealedPropertyValue("PrimaryNameAttribute", "fullname");

                entityMetadata.Attributes.First(a => a.LogicalName == "firstname").SetSealedPropertyValue("DisplayName", new Label("First Name", 1033));
                entityMetadata.Attributes.First(a => a.LogicalName == "fullname").SetSealedPropertyValue("DisplayName", new Label("Full Name", 1033));
                entityMetadata.Attributes.First(a => a.LogicalName == "lastname").SetSealedPropertyValue("DisplayName", new Label("Last Name", 1033));
                entityMetadata.Attributes.First(a => a.LogicalName == "birthdate").SetSealedPropertyValue("DisplayName", new Label("Birthday", 1033));
                entityMetadata.Attributes.First(a => a.LogicalName == "emailaddress1").SetSealedPropertyValue("DisplayName", new Label("Email", 1033));
                entityMetadata.Attributes.First(a => a.LogicalName == "contactid").SetSealedPropertyValue("DisplayName", new Label("Contact", 1033));

                var response = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetMultiValueIdentifierFetch());
            DataBuilder.SetIdentifier(SupportMethods.ContactLogicalName, new String[] { "firstname", "lastname", "birthdate" });
            Assert.AreEqual(
                DataBuilder.BuildSchemaXML().InnerXml,
                SupportMethods.GetMultiValueIdentifierEntityExpectedSchema());
        }
Ejemplo n.º 29
0
        public void CustomerType()
        {
            // CustomerType         customerid                         incident
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.IncidentLogicalName,
                SupportMethods.IncidentDisplayName,
                SupportMethods.GetCustomerTypeEntity());

            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var entityMetadata         = fakedContext.GetEntityMetadataByName(SupportMethods.IncidentLogicalName);
                entityMetadata.DisplayName = new Label(SupportMethods.IncidentDisplayName, 1033);
                entityMetadata.SetSealedPropertyValue("PrimaryNameAttribute", "title");

                entityMetadata.Attributes.First(a => a.LogicalName == "customerid").SetSealedPropertyValue("DisplayName", new Label("Customer", 1033));
                entityMetadata.Attributes.First(a => a.LogicalName == "customerid").SetSealedPropertyValue("AttributeType", Sdk.Metadata.AttributeTypeCode.Customer);
                entityMetadata.Attributes.First(a => a.LogicalName == "customerid").SetSealedPropertyValue("Targets", new String[] { "account", "contact" });
                entityMetadata.Attributes.First(a => a.LogicalName == "incidentid").SetSealedPropertyValue("DisplayName", new Label("Case", 1033));

                var response = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetCustomerTypeFetch());
            Assert.AreEqual(
                DataBuilder.BuildSchemaXML().InnerXml,
                SupportMethods.GetCustomerTypeExpectedSchema());
        }
        public void InvalidAttributeTypeCode_Throws()
        {
            XrmFakedContext fakedContext = SupportMethods.SetupPrimitiveFakedService(
                SupportMethods.IncidentLogicalName,
                SupportMethods.IncidentDisplayName,
                SupportMethods.GetCustomerTypeEntity());

            fakedContext.AddExecutionMock <RetrieveEntityRequest>(req =>
            {
                var entityMetadata         = fakedContext.GetEntityMetadataByName(SupportMethods.IncidentLogicalName);
                entityMetadata.DisplayName = new Label(SupportMethods.IncidentDisplayName, 1033);
                entityMetadata.SetSealedPropertyValue("PrimaryNameAttribute", "title");

                entityMetadata.Attributes.First(a => a.LogicalName == "customerid").SetSealedPropertyValue("DisplayName", new Label("Customer", 1033));
                entityMetadata.Attributes.First(a => a.LogicalName == "customerid").SetSealedPropertyValue("AttributeType", (Sdk.Metadata.AttributeTypeCode) 21);
                entityMetadata.Attributes.First(a => a.LogicalName == "customerid").SetSealedPropertyValue("Targets", new String[] { "account", "contact" });
                entityMetadata.Attributes.First(a => a.LogicalName == "incidentid").SetSealedPropertyValue("DisplayName", new Label("Case", 1033));

                var response = new RetrieveEntityResponse()
                {
                    Results = new ParameterCollection
                    {
                        { "EntityMetadata", entityMetadata }
                    }
                };
                return(response);
            });

            IOrganizationService fakedService = fakedContext.GetOrganizationService();

            DataBuilder DataBuilder = new DataBuilder(fakedService);

            DataBuilder.AppendData(SupportMethods.GetCustomerTypeFetch());

            var ex = Assert.ThrowsException <Exception>(() => DataBuilder.BuildSchemaXML());

            Assert.AreEqual(ex.Message, "GetFieldNodeType: Unknown Field Node Type - incident:customerid - LookupType:21");
        }