本文整理汇总了C#中TestODataMetadataLevel类的典型用法代码示例。如果您正苦于以下问题:C# TestODataMetadataLevel类的具体用法?C# TestODataMetadataLevel怎么用?C# TestODataMetadataLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestODataMetadataLevel类属于命名空间,在下文中一共展示了TestODataMetadataLevel类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldSuppressTypeNameSerialization
public void ShouldSuppressTypeNameSerialization(TestODataMetadataLevel metadataLevel, bool expectedResult)
{
// Act
bool actualResult = ODataComplexTypeSerializer.ShouldSuppressTypeNameSerialization(
(ODataMetadataLevel)metadataLevel);
// Assert
Assert.Equal(expectedResult, actualResult);
}
示例2: CreateODataAction_OmitsAction_WhenFollowingConventions
public void CreateODataAction_OmitsAction_WhenFollowingConventions(TestODataMetadataLevel metadataLevel)
{
// Arrange
IEdmAction action = CreateFakeAction("IgnoreAction", isBindable: true);
ActionLinkBuilder linkBuilder = new ActionLinkBuilder((a) => new Uri("aa://Ignore"),
followsConventions: true);
IEdmDirectValueAnnotationsManager annotationsManager = CreateFakeAnnotationsManager();
annotationsManager.SetActionLinkBuilder(action, linkBuilder);
IEdmModel model = CreateFakeModel(annotationsManager);
UrlHelper url = CreateMetadataLinkFactory("http://IgnoreMetadataPath");
EntityInstanceContext context = CreateContext(model, url);
context.SerializerContext.MetadataLevel = (ODataMetadataLevel)metadataLevel;
// Act
ODataAction actualAction = _serializer.CreateODataAction(action, context);
// Assert
Assert.Null(actualAction);
}
示例3: TestShouldOmitAction
public void TestShouldOmitAction(TestODataMetadataLevel metadataLevel,
bool followsConventions, bool expectedResult)
{
// Arrange
IEdmActionImport action = CreateFakeActionImport(true);
IEdmDirectValueAnnotationsManager annonationsManager = CreateFakeAnnotationsManager();
IEdmModel model = CreateFakeModel(annonationsManager);
ActionLinkBuilder builder = new ActionLinkBuilder((a) => { throw new NotImplementedException(); },
followsConventions);
// Act
bool actualResult = ODataEntityTypeSerializer.ShouldOmitAction(action.Action, builder,
(ODataMetadataLevel)metadataLevel);
// Assert
Assert.Equal(expectedResult, actualResult);
}
示例4: ShouldSuppressTypeNameSerialization
public void ShouldSuppressTypeNameSerialization(string entryType, string entitySetType,
TestODataMetadataLevel metadataLevel, bool expectedResult)
{
// Arrange
ODataEntry entry = new ODataEntry
{
// The caller uses a namespace-qualified name, which this test leaves empty.
TypeName = "." + entryType
};
IEdmEntityType edmType = CreateEntityTypeWithName(entitySetType);
// Act
bool actualResult = ODataEntityTypeSerializer.ShouldSuppressTypeNameSerialization(entry, edmType,
(ODataMetadataLevel)metadataLevel);
// Assert
Assert.Equal(expectedResult, actualResult);
}
示例5: CreateODataAction_IncludesTarget
public void CreateODataAction_IncludesTarget(TestODataMetadataLevel metadataLevel, bool followsConventions)
{
// Arrange
Uri expectedTarget = new Uri("aa://Target");
IEdmAction action = CreateFakeAction("IgnoreAction");
ActionLinkBuilder linkBuilder = new ActionLinkBuilder((a) => expectedTarget, followsConventions);
IEdmDirectValueAnnotationsManager annotationsManager = CreateFakeAnnotationsManager();
annotationsManager.SetActionLinkBuilder(action, linkBuilder);
IEdmModel model = CreateFakeModel(annotationsManager);
UrlHelper url = CreateMetadataLinkFactory("http://IgnoreMetadataPath");
EntityInstanceContext context = CreateContext(model, url);
context.SerializerContext.MetadataLevel = (ODataMetadataLevel)metadataLevel;
// Act
ODataAction actualAction = _serializer.CreateODataAction(action, context);
// Assert
Assert.NotNull(actualAction);
Assert.Equal(expectedTarget, actualAction.Target);
}
示例6: CreateODataAction_OmitsTitle
public void CreateODataAction_OmitsTitle(TestODataMetadataLevel metadataLevel)
{
// Arrange
IEdmEntityContainer container = CreateFakeContainer("IgnoreContainer");
IEdmFunctionImport functionImport = CreateFakeFunctionImport(container, "IgnoreAction");
ActionLinkBuilder linkBuilder = new ActionLinkBuilder((a) => new Uri("aa://Ignore"),
followsConventions: false);
IEdmDirectValueAnnotationsManager annotationsManager = CreateFakeAnnotationsManager();
annotationsManager.SetActionLinkBuilder(functionImport, linkBuilder);
IEdmModel model = CreateFakeModel(annotationsManager);
UrlHelper url = CreateMetadataLinkFactory("http://IgnoreMetadataPath");
EntityInstanceContext context = CreateContext(model, url);
context.SerializerContext.MetadataLevel = (ODataMetadataLevel)metadataLevel;
// Act
ODataAction actualAction = _serializer.CreateODataAction(functionImport, context);
// Assert
Assert.NotNull(actualAction);
Assert.Null(actualAction.Title);
}
示例7: ShouldSuppressTypeNameSerialization
public void ShouldSuppressTypeNameSerialization(object value, TestODataMetadataLevel metadataLevel,
bool expectedResult)
{
// Act
bool actualResult = ODataPrimitiveSerializer.ShouldSuppressTypeNameSerialization(value,
(ODataMetadataLevel)metadataLevel);
// Assert
Assert.Equal(expectedResult, actualResult);
}
示例8: CreateMetadataFragment_OmitsDefaultContainerName
public void CreateMetadataFragment_OmitsDefaultContainerName(TestODataMetadataLevel metadataLevel)
{
// Arrange
string expectedActionName = "Action";
IEdmEntityContainer container = CreateFakeContainer("ContainerShouldNotAppearInResult");
IEdmFunctionImport action = CreateFakeFunctionImport(container, expectedActionName);
IEdmDirectValueAnnotationsManager annotationsManager = CreateFakeAnnotationsManager();
annotationsManager.SetDefaultContainer(container);
IEdmModel model = CreateFakeModel(annotationsManager);
// Act
string actualFragment = ODataEntityTypeSerializer.CreateMetadataFragment(action, model,
(ODataMetadataLevel)metadataLevel);
// Assert
Assert.Equal(expectedActionName, actualFragment);
}
示例9: ShouldAddTypeNameAnnotation
public void ShouldAddTypeNameAnnotation(TestODataMetadataLevel metadataLevel, bool expectedResult)
{
// Act
bool actualResult = ODataEntityTypeSerializer.ShouldAddTypeNameAnnotation(
(ODataMetadataLevel)metadataLevel);
// Assert
Assert.Equal(expectedResult, actualResult);
}
示例10: CreateMetadataFragment_IncludesNonDefaultContainerName
public void CreateMetadataFragment_IncludesNonDefaultContainerName(TestODataMetadataLevel metadataLevel)
{
// Arrange
string expectedContainerName = "Container";
string expectedActionName = "Action";
IEdmEntityContainer container = CreateFakeContainer(expectedContainerName);
IEdmFunctionImport action = CreateFakeFunctionImport(container, expectedActionName);
IEdmModel model = CreateFakeModel();
// Act
string actualFragment = ODataEntityTypeSerializer.CreateMetadataFragment(action, model,
(ODataMetadataLevel)metadataLevel);
// Assert
Assert.Equal(expectedContainerName + "." + expectedActionName, actualFragment);
}
示例11: CreateODataAction_IncludesTitle
public void CreateODataAction_IncludesTitle(TestODataMetadataLevel metadataLevel)
{
// Arrange
string expectedActionName = "Action";
IEdmEntityContainer container = CreateFakeContainer("IgnoreContainer");
IEdmFunctionImport functionImport = CreateFakeFunctionImport(container, expectedActionName);
ActionLinkBuilder linkBuilder = new ActionLinkBuilder((a) => new Uri("aa://IgnoreTarget"),
followsConventions: false);
IEdmDirectValueAnnotationsManager annotationsManager = CreateFakeAnnotationsManager();
annotationsManager.SetActionLinkBuilder(functionImport, linkBuilder);
IEdmModel model = CreateFakeModel(annotationsManager);
UrlHelper url = CreateMetadataLinkFactory("http://IgnoreMetadataPath");
EntityInstanceContext context = CreateContext(model, url);
// Act
ODataAction actualAction = ODataEntityTypeSerializer.CreateODataAction(functionImport, context,
(ODataMetadataLevel)metadataLevel);
// Assert
Assert.NotNull(actualAction);
Assert.Equal(expectedActionName, actualAction.Title);
}
示例12: CreateODataFunction_OmitsAction_WhenFollowingConventions
public void CreateODataFunction_OmitsAction_WhenFollowingConventions(TestODataMetadataLevel metadataLevel)
{
// Arrange
IEdmTypeReference returnType = EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Boolean, isNullable: false);
IEdmFunction function = new EdmFunction("NS", "Function", returnType, isBound: true, entitySetPathExpression: null, isComposable: false);
FunctionLinkBuilder linkBuilder = new FunctionLinkBuilder((EntityInstanceContext a) => new Uri("aa://Ignore"),
followsConventions: true);
IEdmDirectValueAnnotationsManager annotationsManager = CreateFakeAnnotationsManager();
annotationsManager.SetFunctionLinkBuilder(function, linkBuilder);
IEdmModel model = CreateFakeModel(annotationsManager);
UrlHelper url = CreateMetadataLinkFactory("http://IgnoreMetadataPath");
EntityInstanceContext context = CreateContext(model, url);
context.SerializerContext.MetadataLevel = (ODataMetadataLevel)metadataLevel;
// Act
ODataFunction actualFunction = _serializer.CreateODataFunction(function, context);
// Assert
Assert.Null(actualFunction);
}
示例13: TestShouldOmitAction
public void TestShouldOmitAction(TestODataMetadataLevel metadataLevel, bool isAlwaysAvailable, bool expectedResult)
{
// Arrange
IEdmFunctionImport action = CreateFakeFunctionImport(true);
IEdmDirectValueAnnotationsManager annonationsManager = CreateFakeAnnotationsManager();
if (isAlwaysAvailable)
{
annonationsManager.SetIsAlwaysBindable(action);
}
IEdmModel model = CreateFakeModel(annonationsManager);
// Act
bool actualResult = ODataEntityTypeSerializer.ShouldOmitAction(action, model,
(ODataMetadataLevel)metadataLevel);
// Assert
Assert.Equal(expectedResult, actualResult);
}
示例14: ShouldSuppressTypeNameSerialization
public void ShouldSuppressTypeNameSerialization(string entryType, string entitySetType,
TestODataMetadataLevel metadataLevel, bool expectedResult)
{
// Arrange
ODataEntry entry = new ODataEntry
{
TypeName = entryType
};
IEdmEntitySet entitySet = CreateEntitySetWithElementTypeName(entitySetType);
// Act
bool actualResult = ODataEntityTypeSerializer.ShouldSuppressTypeNameSerialization(entry, null,
(ODataMetadataLevel)metadataLevel);
// Assert
Assert.Equal(expectedResult, actualResult);
}