当前位置: 首页>>代码示例>>C#>>正文


C# XrmFakedContext.CreateQuery方法代码示例

本文整理汇总了C#中XrmFakedContext.CreateQuery方法的典型用法代码示例。如果您正苦于以下问题:C# XrmFakedContext.CreateQuery方法的具体用法?C# XrmFakedContext.CreateQuery怎么用?C# XrmFakedContext.CreateQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XrmFakedContext的用法示例。


在下文中一共展示了XrmFakedContext.CreateQuery方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: When_set_state_request_is_called_an_entity_is_updated

        public void When_set_state_request_is_called_an_entity_is_updated()
        {
            var context = new XrmFakedContext();
            context.ProxyTypesAssembly = Assembly.GetExecutingAssembly();
            var service = context.GetFakedOrganizationService();

            var c = new Contact() {
                Id = Guid.NewGuid()
            }; 
            context.Initialize(new[] { c });

            var request = new SetStateRequest
            {
                EntityMoniker = c.ToEntityReference(),
                State = new OptionSetValue(69), 
                Status = new OptionSetValue(6969),
            };

            var response = service.Execute(request);

            //Retrieve record after update
            var contact = (from con in context.CreateQuery<Contact>()
                           where con.Id == c.Id
                           select con).FirstOrDefault();

            Assert.Equal((int) contact.StateCode.Value, 69);
            Assert.Equal((int) contact.StatusCode.Value, 6969);
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:28,代码来源:SetStateRequestTests.cs

示例2: When_execute_is_called_all_requests_are_executed

        public void When_execute_is_called_all_requests_are_executed()
        {
            var context = new XrmFakedContext();
            var executor = new ExecuteTransactionExecutor();
            var req = new ExecuteTransactionRequest()
            {
                Requests = new OrganizationRequestCollection()
                {
                    new CreateRequest() { Target = new Entity("contact") },
                    new CreateRequest() { Target = new Entity("contact") },
                    new CreateRequest() { Target = new Entity("contact") }
                }
            };

            var response = executor.Execute(req, context) as ExecuteTransactionResponse;
            var contacts = context.CreateQuery("contact").ToList();
            Assert.Equal(0, response.Responses.Count);
            Assert.Equal(3, contacts.Count);
        }
开发者ID:DigitalFlow,项目名称:fake-xrm-easy,代码行数:19,代码来源:ExecuteTransactionTests.cs

示例3: Should_set_a_statecode_by_default_when_an_entity_record_is_added_to_the_context

        public void Should_set_a_statecode_by_default_when_an_entity_record_is_added_to_the_context()
        {
            var context = new XrmFakedContext();
            context.ProxyTypesAssembly = Assembly.GetExecutingAssembly();
            var service = context.GetFakedOrganizationService();

            var c = new Contact()
            {
                Id = Guid.NewGuid()
            };
            context.Initialize(new[] { c });

            //Retrieve record after update
            var contact = (from con in context.CreateQuery<Contact>()
                           where con.Id == c.Id
                           select con).FirstOrDefault();

            Assert.Equal((int)contact.StateCode.Value, 0); //Active
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:19,代码来源:SetStateRequestTests.cs

示例4: Should_not_override_a_statecode_already_initialized

        public void Should_not_override_a_statecode_already_initialized()
        {
            var context = new XrmFakedContext();
            context.ProxyTypesAssembly = Assembly.GetExecutingAssembly();
            var service = context.GetFakedOrganizationService();

            var c = new Contact()
            {
                Id = Guid.NewGuid(),
            };

            c["statecode"] = new OptionSetValue(69); //As the StateCode is read only in the early bound entity, this is the only way of updating it
             
            context.Initialize(new[] { c });

            //Retrieve record after update
            var contact = (from con in context.CreateQuery<Contact>()
                           where con.Id == c.Id
                           select con).FirstOrDefault();

            Assert.Equal((int)contact.StateCode.Value, 69); //Set
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:22,代码来源:SetStateRequestTests.cs


注:本文中的XrmFakedContext.CreateQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。