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


C# XrmFakedContext.GetOrganizationService方法代码示例

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


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

示例1: Should_Not_Change_Context_Objects_Without_Update

        public void Should_Not_Change_Context_Objects_Without_Update()
        {
            var entityId = Guid.NewGuid();
            var context = new XrmFakedContext();
            var service = context.GetOrganizationService();

            context.Initialize(new[] {
                new Entity ("account")
                {
                    Id = entityId,
                    Attributes = new AttributeCollection
                    {
                        { "accountname", "Adventure Works" }
                    }
                }
            });

            var firstRetrieve = service.Retrieve("account", entityId, new ColumnSet(true));
            var secondRetrieve = service.Retrieve("account", entityId, new ColumnSet(true));

            firstRetrieve["accountname"] = "Updated locally";

            Assert.Equal("Updated locally", firstRetrieve["accountname"]);
            Assert.Equal("Adventure Works", secondRetrieve["accountname"]);
        }
开发者ID:DigitalFlow,项目名称:fake-xrm-easy,代码行数:25,代码来源:FakeContextTestUpdate.cs

示例2: Should_update_an_entity_when_calling_update

        public void Should_update_an_entity_when_calling_update()
        {
            var ctx = new XrmFakedContext();
            var logSystem = A.Fake<IDetailedLog>();
            var service = ctx.GetOrganizationService();

            //Arrange
            var contact = new Entity("contact") { Id = Guid.NewGuid() };
            contact["fullname"] = "Lionel Messi";

            ctx.Initialize(new Entity[]
            {
                contact
            });

            //Act
            var contactToUpdate = new Entity("contact") { Id = contact.Id };
            contactToUpdate["fullname"] = "Luis Suárez";

            var actions = new Actions(logSystem, service);
            actions.Update(contactToUpdate);

            //Assert
            var contacts = ctx.CreateQuery("contact").ToList();
            Assert.Equal(1, contacts.Count);
            Assert.Equal(contacts[0]["fullname"], "Luis Suárez");
        }
开发者ID:bkanlica,项目名称:CubeXrmFramework,代码行数:27,代码来源:ActionTests.cs

示例3: AccountTests

        // Test class constructor
        public AccountTests()
        {
            // Create fake service
            fakeContext = new XrmFakedContext();
            fakeService = fakeContext.GetOrganizationService();

            // Create real service
            realContext = new MyContext("XRM");
            realService = realContext.GetOrganizationService();
        }
开发者ID:BISmb,项目名称:Projects,代码行数:11,代码来源:AccountTests.cs

示例4: Should_create_a_new_entity_when_calling_create

        public void Should_create_a_new_entity_when_calling_create()
        {
            var ctx = new XrmFakedContext();
            var logSystem = A.Fake<IDetailedLog>();
            var service = ctx.GetOrganizationService();

            //Arrange
            var actions = new Actions(logSystem, service);
            var contact = new Entity("contact");
            contact["fullname"] = "Lionel Messi";

            //Act
            actions.Create(contact);

            //Assert
            var contactCreated = ctx.CreateQuery("contact").FirstOrDefault();
            Assert.NotNull(contactCreated);
            Assert.Equal(contactCreated["fullname"], "Lionel Messi");
        }
开发者ID:bkanlica,项目名称:CubeXrmFramework,代码行数:19,代码来源:ActionTests.cs

示例5: Should_delete_an_entisting_record_when_calling_delete

        public void Should_delete_an_entisting_record_when_calling_delete()
        {
            var ctx = new XrmFakedContext();
            var logSystem = A.Fake<IDetailedLog>();
            var service = ctx.GetOrganizationService();

            //Arrange
            var contact = new Entity("contact") { Id = Guid.NewGuid() };
            contact["fullname"] = "Lionel Messi";

            ctx.Initialize(new Entity[]
            {
                contact
            });

            //Act
            var actions = new Actions(logSystem, service);
            actions.Delete(contact.Id, "contact");

            //Assert
            var contacts = ctx.CreateQuery("contact").ToList();
            Assert.Equal(0, contacts.Count);
        }
开发者ID:bkanlica,项目名称:CubeXrmFramework,代码行数:23,代码来源:ActionTests.cs

示例6: Should_Not_Change_Context_Objects_Without_Update_And_Retrieve_Multiple

        public void Should_Not_Change_Context_Objects_Without_Update_And_Retrieve_Multiple()
        {
            var entityId = Guid.NewGuid();
            var context = new XrmFakedContext();
            var service = context.GetOrganizationService();

            context.Initialize(new[] {
                new Account
                {
                    Id = entityId,
                    Name = "Adventure Works"
                }
            });

            Account firstRetrieve, secondRetrieve = null;
            using (var ctx = new XrmServiceContext(service))
            {
                firstRetrieve = ctx.CreateQuery<Account>()
                                    .Where(a => a.AccountId == entityId)
                                    .FirstOrDefault();

            }

            using (var ctx = new XrmServiceContext(service))
            {
                secondRetrieve = ctx.CreateQuery<Account>()
                                    .Where(a => a.AccountId == entityId)
                                    .FirstOrDefault();

            }

            firstRetrieve.Name = "Updated locally";

            Assert.False(firstRetrieve == secondRetrieve);
            Assert.Equal("Updated locally", firstRetrieve.Name);
            Assert.Equal("Adventure Works", secondRetrieve.Name);
        }
开发者ID:DigitalFlow,项目名称:fake-xrm-easy,代码行数:37,代码来源:FakeContextTestUpdate.cs


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