コード例 #1
0
        public void GetRelatedDirectTest()
        {
            /// Arrange
            EntityReference account1 = new EntityReference();

            account1.LogicalName = "account";
            account1.Id          = Guid.NewGuid();

            EntityReference account2 = new EntityReference();

            account2.LogicalName = "account";
            account2.Id          = Guid.NewGuid();

            EntityReference contact1 = new EntityReference();

            contact1.LogicalName = "contact";
            contact1.Id          = Guid.NewGuid();

            EntityReference contact2 = new EntityReference();

            contact2.LogicalName = "contact";
            contact2.Id          = Guid.NewGuid();

            ParameterCollection inputParameters = new ParameterCollection();

            inputParameters.Add("Target", account1);
            inputParameters.Add("RelatedEntities", new EntityReferenceCollection()
            {
                contact1, contact2
            });

            TestPluginExecutionContext context = new TestPluginExecutionContext();

            context.InputParameters = inputParameters;
            context.MessageName     = "Associate";

            /// Act
            var dic = context.GetRelatedEntitiesByTarget(account1.LogicalName, contact1.LogicalName);

            /// Assert
            Assert.AreEqual(1, dic.Count);
            Assert.IsTrue(dic.Keys.Contains(account1));

            EntityReferenceCollection value = dic[account1];

            Assert.AreEqual(2, value.Count);
            Assert.IsTrue(value.Contains(contact1));
            Assert.IsTrue(value.Contains(contact2));
        }