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