示例#1
0
        public void Test_plugin_2011_multiple_retrievemultiple()
        {
            //Arrange

            //Create the plug-in mock
            CrmPluginMock pluginMock = new CrmPluginMock();

            //Define the result of the first query - type QueryExpressions
            EntityCollection accounts = new EntityCollection
            {
                Entities =
                {
                    new Entity("account")
                    {
                        Id = Guid.NewGuid(), ["name"] = "test1", ["telephone1"] = "555-555-5555"
                    },
                    new Entity("account")
                    {
                        Id = Guid.NewGuid(), ["name"] = "test2", ["telephone1"] = "333-333-3333"
                    }
                }
            };

            //Define the result of the first query - type FetchExpression
            EntityCollection contacts = new EntityCollection
            {
                Entities =
                {
                    new Entity("contact")
                    {
                        Id = Guid.NewGuid(), ["fullname"] = "Joe Smith", ["telephone1"] = "444-444-4444"
                    },
                    new Entity("contact")
                    {
                        Id = Guid.NewGuid(), ["fullname"] = "Bob Smith", ["telephone1"] = "777-777-7777"
                    }
                }
            };

            //Set the RetrieveMultiple responses
            pluginMock.SetMockRetrieveMultiples(accounts, contacts);

            //Act

            //Execute the plug-in
            ExamplePlugin2 examplePlugin2 = new ExamplePlugin2(String.Empty, String.Empty);
            int            count          = examplePlugin2.GetAccountAndContactCount(pluginMock.FakeOrganizationService);

            //Assert

            //Review the test Output to see the configuration values
            Assert.AreEqual(count, 4);
        }