本文整理汇总了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"]);
}
示例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");
}
示例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();
}
示例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");
}
示例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);
}
示例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);
}