本文整理汇总了C#中BaseEntity.Union方法的典型用法代码示例。如果您正苦于以下问题:C# BaseEntity.Union方法的具体用法?C# BaseEntity.Union怎么用?C# BaseEntity.Union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseEntity
的用法示例。
在下文中一共展示了BaseEntity.Union方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BaseEntity
public void ODataTypeAnnotationAppearsForAllEntitiesInFullMetadataAndForDerivedEntityTypesInFullAndMinimalMetadata(string acceptHeader)
{
//Arrange
BaseEntity[] baseEntities = new BaseEntity[] { new BaseEntity(1), new BaseEntity(2), new BaseEntity(3), new BaseEntity(4), new BaseEntity(5), new BaseEntity(6), new BaseEntity(7) }; //InstanceCreator.CreateInstanceOf<BaseEntity[]>(new Random(RandomSeedGenerator.GetRandomSeed()));
DerivedEntity[] derivedEntities = new DerivedEntity[] { new DerivedEntity(8), new DerivedEntity(9), new DerivedEntity(10), new DerivedEntity(11), new DerivedEntity(12), new DerivedEntity(13), new DerivedEntity(14) }; //InstanceCreator.CreateInstanceOf<DerivedEntity[]>(new Random(RandomSeedGenerator.GetRandomSeed()));
BaseEntity[] entities = baseEntities.Union(derivedEntities, new BaseEntity.IdEqualityComparer()).ToArray();
string requestUrl = BaseAddress.ToLowerInvariant() + "/Inheritance/BaseEntity/";
string expectedTypeName;
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUrl);
request.SetAcceptHeader(acceptHeader);
//Act
HttpResponseMessage response = Client.SendAsync(request).Result;
JObject result = response.Content.ReadAsJObject();
//Assert
JArray returnedEntities = (JArray)result["value"];
for (int i = 0; i < returnedEntities.Count; i++)
{
JObject returnedEntity = (JObject)returnedEntities[i];
BaseEntity originalEntity = entities.FirstOrDefault(x => x.Id == (int)returnedEntity["Id"]);
Assert.NotNull(originalEntity);
if (acceptHeader.Contains("nometadata"))
{
JsonAssert.DoesNotContainProperty("odata.type", returnedEntity);
}
else if (acceptHeader.Contains("fullmetadata"))
{
expectedTypeName = originalEntity.GetType().FullName;
JsonAssert.Equal(expectedTypeName, "odata.type", returnedEntity);
}
else
{
if (originalEntity is DerivedEntity)
{
expectedTypeName = originalEntity.GetType().FullName;
JsonAssert.Equal(expectedTypeName, "odata.type", returnedEntity);
}
else
{
JsonAssert.DoesNotContainProperty("odata.type", returnedEntity);
}
}
}
}