public void UpdateIfResultsAreReturned()
        {
            var context    = new XrmFakedContext();
            var orgService = context.GetOrganizationService();

            context.Initialize(new List <Entity>()
            {
                TestAccount1
            });

            TestAccount1.CreateOrUpdate(orgService, SampleAccountQueryExpression);

            Assert.IsNotNull(TestAccount1.Id);
        }
        public void BasicDisassociateTest()
        {
            var context    = new XrmFakedContext();
            var orgService = context.GetOrganizationService();

            context.AddRelationship("account_primary_contact", new XrmFakedRelationship()
            {
                RelationshipType   = XrmFakedRelationship.enmFakeRelationshipType.OneToMany,
                Entity1LogicalName = "contact",
                Entity1Attribute   = "contactid",
                Entity2LogicalName = "account",
                Entity2Attribute   = "contactid"
            });

            context.Initialize(new List <Entity>()
            {
                TestAccount1,
                TestAccount1Duplicate
            });

            var contact = new Contact()
            {
                FirstName = "Jaroslaw",
                LastName  = "Czyz"
            };

            contact.Create(orgService);

            var accountCollection = new EntityReferenceCollection()
            {
                TestAccount1.ToEntityReference(),
                TestAccount1Duplicate.ToEntityReference()
            };

            contact.Associate(orgService, "account_primary_contact", accountCollection);

            Assert.Throws <FeatureRequestException>(() =>
                                                    contact.Disassociate(orgService, "account_primary_contact", accountCollection));
        }