Ejemplo n.º 1
0
        public void When_execute_is_called_with_a_null_request_exception_is_thrown()
        {
            var context          = new XrmFakedContext();
            var executor         = new AssociateRequestExecutor();
            AssociateRequest req = null;

            Assert.Throws <Exception>(() => executor.Execute(req, context));
        }
Ejemplo n.º 2
0
        public void When_execute_is_called_with_a_null_target_exception_is_thrown()
        {
            var context  = new XrmFakedContext();
            var executor = new AssociateRequestExecutor();
            var req      = new AssociateRequest()
            {
                Target = null, Relationship = new Relationship("fakeRelationship")
            };

            context.AddRelationship("fakeRelationship", new XrmFakedRelationship());
            Assert.Throws <Exception>(() => executor.Execute(req, context));
        }
Ejemplo n.º 3
0
        public void When_execute_is_called_with_a_non_existing_reference_exception_is_thrown()
        {
            var context  = new XrmFakedContext();
            var executor = new AssociateRequestExecutor();

            context.AddRelationship("fakeRelationship",
                                    new XrmFakedRelationship()
            {
                IntersectEntity    = "account_contact_intersect",
                Entity1LogicalName = Contact.EntityLogicalName,
                Entity1Attribute   = "contactid",
                Entity2LogicalName = Account.EntityLogicalName,
                Entity2Attribute   = "accountid"
            });

            var contact = new Entity("contact")
            {
                Id = Guid.NewGuid()
            };
            var account = new Entity("account")
            {
                Id = Guid.NewGuid()
            };

            context.Initialize(new List <Entity>()
            {
                contact
            });
            var req = new AssociateRequest()
            {
                Target          = contact.ToEntityReference(),
                RelatedEntities = new EntityReferenceCollection()
                {
                    new EntityReference(Account.EntityLogicalName, account.Id),
                },
                Relationship = new Relationship("fakeRelationship")
            };

            Assert.Throws <Exception>(() => executor.Execute(req, context));
        }