コード例 #1
0
        public void ImportFromStubImportsStub()
        {
            DatabaseWebCampaign webCampaign = CreateWebCampaign(_campaign, new List <string>()
            {
            });

            webCampaign.Insert(Connection);

            string firstname = $"firstname {Guid.NewGuid()}";

            DatabaseStub stub = CreateStub(webCampaign, firstname);

            DatabaseStubPusher.GetInstance(Connection).Push(stub);

            DatabaseImportFromStub databaseImportFromStub = CreateDatabaseImportStub(webCampaign);

            ImportFromStub importFromStub = new ImportFromStub(Connection, databaseImportFromStub);

            importFromStub.ExecuteOption(new Administration.Option.Options.OptionReport(typeof(ImportFromStubTest)));

            Lead lead = Lead.ReadFromFetchXml(DynamicsCrmConnection, new List <string>()
            {
                "firstname"
            }, new Dictionary <string, string>()
            {
                { "firstname", firstname }
            }).Single();

            lead.Delete();
        }
コード例 #2
0
        public void LeadCanHaveSubscriberIdUpdated()
        {
            string firstname    = $"firstname {Guid.NewGuid()}";
            int    subscriberId = new Random().Next(1, int.MaxValue);

            Lead lead = Lead.Create(_dynamicsCrmConnection, new Dictionary <string, string>()
            {
                { "firstname", firstname }
            });

            lead.InsertWithoutRead();

            Lead.UpdateSubscriberId(_dynamicsCrmConnection, lead.Id, subscriberId);

            Lead leadRead = Lead.ReadFromFetchXml(_dynamicsCrmConnection, new List <string>()
            {
                "leadid", "firstname", "new_mailrelaysubscriberid"
            }, new Dictionary <string, string>()
            {
                { "leadid", lead.Id.ToString() }
            }).Single();

            lead.Delete();

            Assert.AreEqual(firstname, leadRead.firstname);
            Assert.AreEqual(subscriberId, leadRead.new_mailrelaysubscriberid);
        }
コード例 #3
0
        public void ImportFromStubAssignsContactToAccount()
        {
            Account account = CreateAccount();

            account.InsertWithoutRead();

            DatabaseWebCampaign webCampaign = CreateWebCampaign(_campaign, new List <string>()
            {
                "emailaddress1"
            });

            webCampaign.Insert(Connection);

            DatabaseStub stub          = CreateStub(webCampaign);
            string       emailaddress1 = $"emailaddress1 {Guid.NewGuid()}";

            stub.Contents.Add(new DatabaseStubElement()
            {
                Key = "emailaddress1", Value = emailaddress1
            });
            stub.Contents.Add(new DatabaseStubElement()
            {
                Key = "indsamler2016", Value = account.Id.ToString()
            });
            DatabaseStubPusher.GetInstance(Connection).Push(stub);

            DatabaseImportFromStub databaseImportFromStub = CreateDatabaseImportStub(webCampaign);

            ImportFromStub importFromStub = new ImportFromStub(Connection, databaseImportFromStub);

            importFromStub.ExecuteOption(new Administration.Option.Options.OptionReport(typeof(ImportFromStubTest)));

            Lead lead = Lead.ReadFromFetchXml(DynamicsCrmConnection, new List <string>()
            {
                "emailaddress1"
            }, new Dictionary <string, string>()
            {
                { "emailaddress1", emailaddress1 }
            }).Single();
            Contact contact = Contact.ReadFromFetchXml(DynamicsCrmConnection, new List <string>()
            {
                "contactid", "emailaddress1", "new_indsamler2016"
            }, new Dictionary <string, string>()
            {
                { "emailaddress1", emailaddress1 }
            }).Single();
            Account accountRead = Account.ReadFromFetchXml(DynamicsCrmConnection, new List <string>()
            {
                "accountid"
            }, new Dictionary <string, string>()
            {
                { "accountid", contact.indsamler2016.ToString() }
            }).Single();

            lead.Delete();
            contact.Delete();
            accountRead.Delete();
        }
コード例 #4
0
        public void StubWillBeImportedWithoutCampaign()
        {
            string firstname = $"firstname {Guid.NewGuid()}";

            DatabaseStub stub = CreateStub(null, firstname);

            stub.Contents.AddRange(new List <DatabaseStubElement>()
            {
                new DatabaseStubElement()
                {
                    Key = "lastname", Value = "test"
                },
                new DatabaseStubElement()
                {
                    Key = "address1_line1", Value = "test"
                },
                new DatabaseStubElement()
                {
                    Key = "address1_postalcode", Value = "test"
                },
                new DatabaseStubElement()
                {
                    Key = "address1_city", Value = "test"
                },
                new DatabaseStubElement()
                {
                    Key = "emailaddress1", Value = "test"
                },
                new DatabaseStubElement()
                {
                    Key = "mobilephone", Value = "test"
                },
            });
            DatabaseStubPusher.GetInstance(Connection).Push(stub);

            DatabaseImportFromStub databaseImportFromStub = CreateDatabaseImportStub();

            ImportFromStub importFromStub = new ImportFromStub(Connection, databaseImportFromStub);

            importFromStub.ExecuteOption(new Administration.Option.Options.OptionReport(typeof(ImportFromStubTest)));

            Lead lead = Lead.ReadFromFetchXml(DynamicsCrmConnection, new List <string>()
            {
                "firstname"
            }, new Dictionary <string, string>()
            {
                { "firstname", firstname }
            }).Single();

            lead.Delete();
        }
コード例 #5
0
        public void ImportFromStubImportsStubAndCreatesContact()
        {
            DatabaseWebCampaign webCampaign = CreateWebCampaign(_campaign, new List <string>()
            {
                "emailaddress1", "mobilephone"
            });

            webCampaign.Insert(Connection);

            DatabaseStub stub          = CreateStub(webCampaign);
            string       emailaddress1 = $"emailaddress1 {Guid.NewGuid()}";

            stub.Contents.Add(new DatabaseStubElement()
            {
                Key = "emailaddress1", Value = emailaddress1
            });
            DatabaseStubPusher.GetInstance(Connection).Push(stub);

            DatabaseImportFromStub databaseImportFromStub = CreateDatabaseImportStub(webCampaign);

            ImportFromStub importFromStub = new ImportFromStub(Connection, databaseImportFromStub);

            importFromStub.ExecuteOption(new Administration.Option.Options.OptionReport(typeof(ImportFromStubTest)));

            Lead lead = Lead.ReadFromFetchXml(DynamicsCrmConnection, new List <string>()
            {
                "emailaddress1"
            }, new Dictionary <string, string>()
            {
                { "emailaddress1", emailaddress1 }
            }).Single();

            lead.Delete();

            Contact contact = Contact.ReadFromFetchXml(DynamicsCrmConnection, new List <string>()
            {
                "emailaddress1"
            }, new Dictionary <string, string>()
            {
                { "emailaddress1", emailaddress1 }
            }).Single();

            contact.Delete();
        }
コード例 #6
0
        internal IFacadeUpdateResult <LeadData> DeleteLead(object instanceId)
        {
            ArgumentValidator.IsNotNull("instanceId", instanceId);

            FacadeUpdateResult <LeadData> result = new FacadeUpdateResult <LeadData>();
            ILeadService service = UnitOfWork.GetService <ILeadService>();
            var          query   = service.Retrieve(instanceId);

            if (query.HasResult)
            {
                Lead instance  = query.ToBo <Lead>();
                var  saveQuery = instance.Delete();
                result.Merge(saveQuery);
            }
            else
            {
                AddError(result.ValidationResult, "LeadCannotBeFound");
            }

            return(result);
        }
コード例 #7
0
        new public void TearDown()
        {
            base.TearDown();

            _lead.Delete();
        }