Ejemplo n.º 1
0
        public void CrmEnvironmentBuilder_WithChildEntities_IncidentAndAccountButAccountAddedIncidentFirst_Should_CreateAccountFirst()
        {
            //
            // Arrange
            //
            var service  = LocalCrmDatabaseOrganizationService.CreateOrganizationService(LocalCrmDatabaseInfo.Create <CrmContext>(Guid.NewGuid().ToString()));
            var account  = new Id <Account>(Guid.NewGuid());
            var incident = new Id <Incident>(Guid.NewGuid());
            var lead     = new Id <Lead>(Guid.NewGuid());

            // The Account and Incident will be added as Account first, and Incident second.
            // The Lead will force an reorder and the Account incident would normally get placed after the Incident
            var builder = new CrmEnvironmentBuilder().
                          WithEntities(new Id <PhoneCall>(Guid.NewGuid()), incident, account).
                          WithChildEntities(account, incident);

            //
            // Act
            //
            builder.Create(service);


            //
            // Assert
            //

            AssertCrm.Exists(service, account);
            AssertCrm.Exists(service, incident);
        }
Ejemplo n.º 2
0
        public void CrmEnvironmentBuilder_ExceptEntities_GivenIdStruct_Should_CreateAllExceptExcluded()
        {
            //
            // Arrange
            //
            var service = LocalCrmDatabaseOrganizationService.CreateOrganizationService(LocalCrmDatabaseInfo.Create <CrmContext>(Guid.NewGuid().ToString()));

            //
            // Act
            //
            var builder = new CrmEnvironmentBuilder().
                          WithEntities <Ids>().
                          ExceptEntities <Ids.Nested>();

            builder.Create(service);

            //
            // Assert
            //

            AssertCrm.Exists(service, Ids.Value1);
            AssertCrm.Exists(service, Ids.Value2);
            AssertCrm.NotExists(service, Ids.Nested.Value1);
            AssertCrm.NotExists(service, Ids.Nested.Value2);
        }
        public void CrmEnvironmentBuilder_WithChildEntities_BiDirectionalRelationship_Should_PopulateBothIds()
        {
            //
            // Arrange
            //
            var service = LocalCrmDatabaseOrganizationService.CreateOrganizationService(LocalCrmDatabaseInfo.Create <CrmContext>(Guid.NewGuid().ToString()));
            var contact = new Id <Contact>(Guid.NewGuid());
            var account = new Id <Account>(Guid.NewGuid());

            // The Account and Incident will be added as Account first, and Incident second.
            // The Lead will force a reorder and the Account incident would normally get placed after the Incident
            var builder = new CrmEnvironmentBuilder().
                          WithChildEntities(contact, account).
                          WithChildEntities(account, contact);

            //
            // Act
            //
            builder.Create(service);


            //
            // Assert
            //

            AssertCrm.Exists(service, account);
            AssertCrm.Exists(service, contact);
            Assert.AreEqual(contact.EntityReference, service.GetEntity(account).PrimaryContactId);
            Assert.AreEqual(contact.EntityReference, account.Entity.PrimaryContactId);
            Assert.AreEqual(account.EntityReference, service.GetEntity(contact).ParentCustomerId);
            Assert.AreEqual(account.EntityReference, contact.Entity.ParentCustomerId);
        }