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


C# XrmFakedContext.GetFakedOrganizationService方法代码示例

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


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

示例1: When_doing_a_crm_linq_query_with_an_equals_operator_record_is_returned

        public void When_doing_a_crm_linq_query_with_an_equals_operator_record_is_returned()
        {
            var fakedContext = new XrmFakedContext();
            var guid1 = Guid.NewGuid();
            var guid2 = Guid.NewGuid();

            fakedContext.Initialize(new List<Entity>() {
                new Contact() { Id = guid1, FirstName = "Jordi" },
                new Contact() { Id = guid2, FirstName = "Other" }
            });

            var service = fakedContext.GetFakedOrganizationService();

            using (XrmServiceContext ctx = new XrmServiceContext(service))
            {
                var matches = (from c in ctx.CreateQuery<Contact>()
                               where c.FirstName.Equals("Jordi")
                               select c).ToList();

                Assert.True(matches.Count == 1);
                Assert.True(matches[0].FirstName.Equals("Jordi"));

                matches = (from c in ctx.CreateQuery<Contact>()
                               where c.FirstName == "Jordi" //Using now equality operator
                               select c).ToList();

                Assert.True(matches.Count == 1);
                Assert.True(matches[0].FirstName.Equals("Jordi"));
            }
            
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:31,代码来源:FakeContextTestLinqQueries.cs

示例2: XrmFakedContext

        public void When_doing_a_crm_linq_query_and_proxy_types_and_a_selected_attribute_returned_projected_entity_is_thesubclass()
        {
            var fakedContext = new XrmFakedContext();
            var guid1 = Guid.NewGuid();
            var guid2 = Guid.NewGuid();

            fakedContext.Initialize(new List<Entity>() {
                new Contact() { Id = guid1, FirstName = "Jordi" },
                new Contact() { Id = guid2, FirstName = "Other" }
            });

            var service = fakedContext.GetFakedOrganizationService();

            using (XrmServiceContext ctx = new XrmServiceContext(service))
            {
                var matches = (from c in ctx.CreateQuery<Contact>()
                               where c.FirstName.Equals("Jordi")
                               select new
                               {
                                   FirstName = c.FirstName,
                                   CrmRecord = c
                               }).ToList();

                Assert.True(matches.Count == 1);
                Assert.True(matches[0].FirstName.Equals("Jordi"));
                Assert.IsAssignableFrom(typeof(Contact), matches[0].CrmRecord);
                Assert.True(matches[0].CrmRecord.GetType() == typeof(Contact));

            }
        }
开发者ID:DigitalFlow,项目名称:fake-xrm-easy,代码行数:30,代码来源:FakeContextTestLinqQueries.cs

示例3: When_an_entity_is_created_with_an_empty_logical_name_an_exception_is_thrown

        public void When_an_entity_is_created_with_an_empty_logical_name_an_exception_is_thrown()
        {
            var context = new XrmFakedContext();
            var service = context.GetFakedOrganizationService();

            var e = new Entity("") { Id = Guid.Empty };

            var ex = Assert.Throws<InvalidOperationException>(() => service.Create(e));
            Assert.Equal(ex.Message, "The LogicalName property must not be empty");
        }
开发者ID:DigitalFlow,项目名称:fake-xrm-easy,代码行数:10,代码来源:FakeContextTestCreate.cs

示例4: When_getting_a_fake_service_reference_it_uses_a_singleton_pattern

        public void When_getting_a_fake_service_reference_it_uses_a_singleton_pattern()
        {
            var context = new XrmFakedContext();
            var service = context.GetFakedOrganizationService();
            var service2 = context.GetFakedOrganizationService();

            Assert.Equal(service, service2);
        }
开发者ID:DigitalFlow,项目名称:fake-xrm-easy,代码行数:8,代码来源:FakeContextTests.cs

示例5: When_a_query_by_attribute_is_executed_when_one_attribute_right_result_is_returned

        public static void When_a_query_by_attribute_is_executed_when_one_attribute_right_result_is_returned()
        {
            var context = new XrmFakedContext();
            var account = new Account() {Id = Guid.NewGuid(), Name = "Test"};
            var account2 = new Account() { Id = Guid.NewGuid(), Name = "Other account!" };
            context.Initialize(new List<Entity>()
            {
                account, account2
            });

            var service = context.GetFakedOrganizationService();

            QueryByAttribute query = new QueryByAttribute();
            query.Attributes.AddRange(new string[] { "name" });
            query.ColumnSet = new ColumnSet(new string[] { "name" });
            query.EntityName = Account.EntityLogicalName;
            query.Values.AddRange(new object[] { "Test" });

            //Execute using a request to test the OOB (XRM) message contracts
            RetrieveMultipleRequest request = new RetrieveMultipleRequest();
            request.Query = query;
            Collection<Entity> entityList = ((RetrieveMultipleResponse)service.Execute(request)).EntityCollection.Entities;

            Assert.True(entityList.Count == 1);
            Assert.Equal(entityList[0]["name"].ToString(), "Test");
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:26,代码来源:QueryByAttributeTests.cs

示例6: When_using_proxy_types_assembly_the_attribute_metadata_is_inferred_from_the_proxy_types_assembly

        public static void When_using_proxy_types_assembly_the_attribute_metadata_is_inferred_from_the_proxy_types_assembly()
        {
            var fakedContext = new XrmFakedContext();
            fakedContext.ProxyTypesAssembly = Assembly.GetExecutingAssembly();

            var contact1 = new Entity("contact") { Id = Guid.NewGuid() }; contact1["fullname"] = "Contact 1"; contact1["firstname"] = "First 1";
            var contact2 = new Entity("contact") { Id = Guid.NewGuid() }; contact2["fullname"] = "Contact 2"; contact2["firstname"] = "First 2";

            fakedContext.Initialize(new List<Entity>() { contact1, contact2 });

            var guid = Guid.NewGuid();

            //Empty contecxt (no Initialize), but we should be able to query any typed entity without an entity not found exception

            var service = fakedContext.GetFakedOrganizationService();

            using (XrmServiceContext ctx = new XrmServiceContext(service))
            {
                var contact = (from c in ctx.CreateQuery<Contact>()
                               where c.FirstName.Equals("First 1")
                               select c).ToList();

                Assert.True(contact.Count == 1);
            }
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:25,代码来源:MetadataInferenceTests.cs

示例7: When_doing_a_crm_linq_query_and_proxy_types_projection_must_be_applied_after_where_clause

        public void When_doing_a_crm_linq_query_and_proxy_types_projection_must_be_applied_after_where_clause()
        {
            var fakedContext = new XrmFakedContext();
            fakedContext.ProxyTypesAssembly = Assembly.GetExecutingAssembly();

            var guid1 = Guid.NewGuid();
            var guid2 = Guid.NewGuid();

            fakedContext.Initialize(new List<Entity>() {
                new Contact() { Id = guid1, FirstName = "Jordi", LastName = "Montana" },
                new Contact() { Id = guid2, FirstName = "Other" }
            });

            var service = fakedContext.GetFakedOrganizationService();

            using (XrmServiceContext ctx = new XrmServiceContext(service))
            {
                var matches = (from c in ctx.CreateQuery<Contact>()
                               where c.LastName == "Montana"  //Should be able to filter by a non-selected attribute
                               select new
                               {
                                   FirstName = c.FirstName
                               }).ToList();

                Assert.True(matches.Count == 1);
                Assert.True(matches[0].FirstName.Equals("Jordi"));
            }
        }
开发者ID:DigitalFlow,项目名称:fake-xrm-easy,代码行数:28,代码来源:FakeContextTestLinqQueries.cs

示例8: When_retrieve_is_invoked_with_an_empty_guid_an_exception_is_thrown

        public void When_retrieve_is_invoked_with_an_empty_guid_an_exception_is_thrown()
        {
            var context = new XrmFakedContext();
            var service = context.GetFakedOrganizationService();

            var ex = Assert.Throws<InvalidOperationException>(() => service.Retrieve("account", Guid.Empty, new ColumnSet()));
            Assert.Equal(ex.Message, "The id must not be empty.");
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:8,代码来源:FakeContextTestRetrieve.cs

示例9: When_retrieve_is_invoked_with_a_null_columnset_exception_is_thrown

        public void When_retrieve_is_invoked_with_a_null_columnset_exception_is_thrown()
        {
            var context = new XrmFakedContext();
            var service = context.GetFakedOrganizationService();

            var ex = Assert.Throws<InvalidOperationException>(() => service.Retrieve("account", Guid.NewGuid(), null));
            Assert.Equal(ex.Message, "The columnset parameter must not be null.");
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:8,代码来源:FakeContextTestRetrieve.cs

示例10: When_a_null_entity_is_created_an_exception_is_thrown

        public void When_a_null_entity_is_created_an_exception_is_thrown()
        {
            var context = new XrmFakedContext();
            var service = context.GetFakedOrganizationService();

            var ex = Assert.Throws<InvalidOperationException>(() => service.Create(null));
            Assert.Equal(ex.Message, "The entity must not be null");
        }
开发者ID:DigitalFlow,项目名称:fake-xrm-easy,代码行数:8,代码来源:FakeContextTestCreate.cs

示例11: When_an_entity_is_updated_with_an_empty_guid_an_exception_is_thrown

        public void When_an_entity_is_updated_with_an_empty_guid_an_exception_is_thrown()
        {
            var context = new XrmFakedContext();
            var service = context.GetFakedOrganizationService();

            var e = new Entity("account") { Id = Guid.Empty };

            var ex = Assert.Throws<InvalidOperationException>(() => service.Update(e));
            Assert.Equal(ex.Message, "The Id property must not be empty");
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:10,代码来源:FakeContextTestUpdate.cs

示例12: When_a_who_am_i_request_is_invoked_the_caller_id_is_returned

        public static void When_a_who_am_i_request_is_invoked_the_caller_id_is_returned()
        {
            var context = new XrmFakedContext();
            context.CallerId = new EntityReference() { Id = Guid.NewGuid(), Name = "Super Faked User" };

            var service = context.GetFakedOrganizationService();
            WhoAmIRequest req = new WhoAmIRequest();

            var response = service.Execute(req) as WhoAmIResponse;
            Assert.Equal(response.UserId, context.CallerId.Id);
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:11,代码来源:WhoAmITests.cs

示例13: When_adding_an_entity_the_returned_guid_must_not_be_empty_and_the_context_should_have_it

        public void When_adding_an_entity_the_returned_guid_must_not_be_empty_and_the_context_should_have_it()
        {
            var context = new XrmFakedContext();
            var service = context.GetFakedOrganizationService();

            var e = new Entity("account") { Id = Guid.Empty };
            var guid = service.Create(e);

            Assert.True(guid != Guid.Empty);
            Assert.True(context.Data.Count == 1);
            Assert.True(context.Data["account"].Count == 1);
        }
开发者ID:DigitalFlow,项目名称:fake-xrm-easy,代码行数:12,代码来源:FakeContextTestCreate.cs

示例14: Querying_a_dynamic_entity_not_present_in_the_context_should_return_no_records

        public void Querying_a_dynamic_entity_not_present_in_the_context_should_return_no_records()
        {
            var context = new XrmFakedContext();

            var service = context.GetFakedOrganizationService();

            //Find the contact
            var contact = (from c in context.CreateQuery("contact")
                           select c).ToList();

            Assert.Equal(contact.Count, 0);
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:12,代码来源:FakeContextTestCreateQuery.cs

示例15: XrmFakedContext

        public void When_initializing_the_context_with_an_entity_it_should_have_default_createdon_createdby_modifiedon_and_modifiedby_attributes()
        {
            var context = new XrmFakedContext();
            var service = context.GetFakedOrganizationService();

            var e = new Entity("account") { Id = Guid.NewGuid() };
            context.Initialize(new List<Entity>() { e });

            Assert.True(e.Attributes.ContainsKey("createdon"));
            Assert.True(e.Attributes.ContainsKey("modifiedon"));
            Assert.True(e.Attributes.ContainsKey("createdby"));
            Assert.True(e.Attributes.ContainsKey("modifiedby"));
        }
开发者ID:DigitalFlow,项目名称:fake-xrm-easy,代码行数:13,代码来源:FakeContextTests.cs


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