本文整理汇总了C#中ODataAction类的典型用法代码示例。如果您正苦于以下问题:C# ODataAction类的具体用法?C# ODataAction怎么用?C# ODataAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataAction类属于命名空间,在下文中一共展示了ODataAction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PropertyGettersAndSettersTest
public void PropertyGettersAndSettersTest()
{
Uri metadata = new Uri("http://odata.org/operationMetadata");
string title = "OperationTitle";
Uri target = new Uri("http://odata.org/operationtarget");
ODataAction action = new ODataAction()
{
Metadata = metadata,
Title = title,
Target = target,
};
this.Assert.AreSame(metadata, action.Metadata, "Expected reference equal values for property 'Metadata'.");
this.Assert.AreEqual(title, action.Title, "Expected equal Title values.");
this.Assert.AreSame(target, action.Target, "Expected reference equal values for property 'Target'.");
ODataFunction function = new ODataFunction()
{
Metadata = metadata,
Title = title,
Target = target,
};
this.Assert.AreSame(metadata, function.Metadata, "Expected reference equal values for property 'Metadata'.");
this.Assert.AreEqual(title, function.Title, "Expected equal Title values.");
this.Assert.AreSame(target, function.Target, "Expected reference equal values for property 'Target'.");
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:28,代码来源:ODataActionsAndFunctionsTests.cs
示例2: AddAction
/// <summary>
/// Add action to feed.
/// </summary>
/// <param name="action">The action to add.</param>
public void AddAction(ODataAction action)
{
ExceptionUtils.CheckArgumentNotNull(action, "action");
if (!this.actions.Contains(action))
{
this.actions.Add(action);
}
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:ODataFeed.cs
示例3: DefaultValuesTest
public void DefaultValuesTest()
{
ODataAction action = new ODataAction();
this.Assert.IsNull(action.Metadata, "Expected null default value for property 'Metadata'.");
this.Assert.IsNull(action.Title, "Expected null default value for property 'Title'.");
this.Assert.IsNull(action.Target, "Expected null default value for property 'Target'.");
ODataFunction function = new ODataFunction();
this.Assert.IsNull(function.Metadata, "Expected null default value for property 'Metadata'.");
this.Assert.IsNull(function.Title, "Expected null default value for property 'Title'.");
this.Assert.IsNull(function.Target, "Expected null default value for property 'Target'.");
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:12,代码来源:ODataActionsAndFunctionsTests.cs
示例4: MissingOperationGeneratorTests
public MissingOperationGeneratorTests()
{
this.model = new EdmModel();
this.container = new EdmEntityContainer("Fake", "Container");
this.functionEdmMetadata = new EdmFunction("Fake", "FakeFunction", EdmCoreModel.Instance.GetInt32(false), true /*isBound*/, null, true /*isComposable*/);
this.actionEdmMetadata = new EdmAction("Fake", "FakeAction", EdmCoreModel.Instance.GetInt32(false), true/*isBound*/, null /*entitySetPath*/);
this.model.AddElement(this.container);
this.model.AddElement(this.actionEdmMetadata);
this.model.AddElement(this.functionEdmMetadata);
this.allOperations = new EdmOperation[] { this.actionEdmMetadata, this.functionEdmMetadata };
this.odataAction = new ODataAction {Metadata = new Uri("http://temp.org/$metadata#Fake.FakeAction")};
this.odataFunction = new ODataFunction {Metadata = new Uri("http://temp.org/$metadata#Fake.FakeFunction")};
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:15,代码来源:MissingOperationGeneratorTests.cs
示例5: PropertySettersNullTest
public void PropertySettersNullTest()
{
Uri metadata = new Uri("http://odata.org/operationMetadata");
string title = "OperationTitle";
Uri target = new Uri("http://odata.org/operationtarget");
ODataAction action = new ODataAction()
{
Metadata = metadata,
Title = title,
Target = target,
};
action.Metadata = null;
action.Title = null;
action.Target = null;
this.Assert.IsNull(action.Metadata, "Expected null value for property 'Metadata'.");
this.Assert.IsNull(action.Title, "Expected null value for property 'Title'.");
this.Assert.IsNull(action.Target, "Expected null value for property 'Target'.");
ODataFunction function = new ODataFunction()
{
Metadata = metadata,
Title = title,
Target = target,
};
function.Metadata = null;
function.Title = null;
function.Target = null;
this.Assert.IsNull(function.Metadata, "Expected null value for property 'Metadata'.");
this.Assert.IsNull(function.Title, "Expected null value for property 'Title'.");
this.Assert.IsNull(function.Target, "Expected null value for property 'Target'.");
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:36,代码来源:ODataActionsAndFunctionsTests.cs
示例6: CreateODataAction
public virtual ODataAction CreateODataAction(IEdmAction action, EntityInstanceContext entityInstanceContext)
{
if (action == null)
{
throw Error.ArgumentNull("action");
}
if (entityInstanceContext == null)
{
throw Error.ArgumentNull("entityInstanceContext");
}
ODataMetadataLevel metadataLevel = entityInstanceContext.SerializerContext.MetadataLevel;
IEdmModel model = entityInstanceContext.EdmModel;
ActionLinkBuilder builder = model.GetActionLinkBuilder(action);
if (builder == null)
{
return null;
}
if (ShouldOmitAction(action, builder, metadataLevel))
{
return null;
}
Uri target = builder.BuildActionLink(entityInstanceContext);
if (target == null)
{
return null;
}
Uri baseUri = new Uri(entityInstanceContext.Url.CreateODataLink(new MetadataPathSegment()));
Uri metadata = new Uri(baseUri, "#" + CreateMetadataFragment(action));
ODataAction odataAction = new ODataAction
{
Metadata = metadata,
};
bool alwaysIncludeDetails = metadataLevel == ODataMetadataLevel.FullMetadata;
// Always omit the title in minimal/no metadata modes.
if (alwaysIncludeDetails)
{
EmitTitle(model, action, odataAction);
}
// Omit the target in minimal/no metadata modes unless it doesn't follow conventions.
if (alwaysIncludeDetails || !builder.FollowsConventions)
{
odataAction.Target = target;
}
return odataAction;
}
开发者ID:BarclayII,项目名称:WebApi,代码行数:58,代码来源:ODataEntityTypeSerializer.cs
示例7: CreateEntry_Calls_CreateODataAction_ForEachSelectAction
public void CreateEntry_Calls_CreateODataAction_ForEachSelectAction()
{
// Arrange
ODataAction[] actions = new ODataAction[] { new ODataAction(), new ODataAction() };
SelectExpandNode selectExpandNode = new SelectExpandNode
{
SelectedActions = { new Mock<IEdmAction>().Object, new Mock<IEdmAction>().Object }
};
Mock<ODataEntityTypeSerializer> serializer = new Mock<ODataEntityTypeSerializer>(_serializerProvider);
serializer.CallBase = true;
serializer.Setup(s => s.CreateODataAction(selectExpandNode.SelectedActions.ElementAt(0), _entityInstanceContext)).Returns(actions[0]).Verifiable();
serializer.Setup(s => s.CreateODataAction(selectExpandNode.SelectedActions.ElementAt(1), _entityInstanceContext)).Returns(actions[1]).Verifiable();
// Act
ODataEntry entry = serializer.Object.CreateEntry(selectExpandNode, _entityInstanceContext);
// Assert
Assert.Equal(actions, entry.Actions);
serializer.Verify();
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:21,代码来源:ODataEntityTypeSerializerTests.cs
示例8: TestSetTitleAnnotation_UsesNameIfNoTitleAnnotationIsPresent
public void TestSetTitleAnnotation_UsesNameIfNoTitleAnnotationIsPresent()
{
// Arrange
IEdmActionImport action = CreateFakeActionImport(CreateFakeContainer("Container"), "Action");
IEdmDirectValueAnnotationsManager annonationsManager = CreateFakeAnnotationsManager();
IEdmModel model = CreateFakeModel(annonationsManager);
ODataAction odataAction = new ODataAction();
// Act
ODataEntityTypeSerializer.EmitTitle(model, action.Operation, odataAction);
// Assert
Assert.Equal(action.Operation.Name, odataAction.Title);
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:14,代码来源:ODataEntityTypeSerializerTests.cs
示例9: CreateODataAction_IncludesEverything_ForFullMetadata
public void CreateODataAction_IncludesEverything_ForFullMetadata()
{
// Arrange
string expectedContainerName = "Container";
string expectedNamespace = "NS";
string expectedActionName = "Action";
string expectedTarget = "aa://Target";
string expectedMetadataPrefix = "http://Metadata";
IEdmEntityContainer container = CreateFakeContainer(expectedContainerName);
IEdmAction action = CreateFakeAction(expectedNamespace, expectedActionName, isBindable: true);
ActionLinkBuilder linkBuilder = new ActionLinkBuilder((a) => new Uri(expectedTarget),
followsConventions: true);
IEdmDirectValueAnnotationsManager annotationsManager = CreateFakeAnnotationsManager();
annotationsManager.SetActionLinkBuilder(action, linkBuilder);
annotationsManager.SetIsAlwaysBindable(action);
IEdmModel model = CreateFakeModel(annotationsManager);
UrlHelper url = CreateMetadataLinkFactory(expectedMetadataPrefix);
EntityInstanceContext context = CreateContext(model, url);
context.SerializerContext.MetadataLevel = ODataMetadataLevel.FullMetadata;
// Act
ODataAction actualAction = _serializer.CreateODataAction(action, context);
// Assert
string expectedMetadata = expectedMetadataPrefix + "#" + expectedNamespace + "." + expectedActionName;
ODataAction expectedAction = new ODataAction
{
Metadata = new Uri(expectedMetadata),
Target = new Uri(expectedTarget),
Title = expectedActionName
};
AssertEqual(expectedAction, actualAction);
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:37,代码来源:ODataEntityTypeSerializerTests.cs
示例10: TryReadOperation
/// <summary>
/// Reads a an m:action or m:function in atom:entry.
/// </summary>
/// <param name="entryState">The reader entry state for the entry being read.</param>
/// <returns>true, if the m:action or m:function was read succesfully, false otherwise.</returns>
/// <remarks>
/// Pre-Condition: XmlNodeType.Element m:action|m:function - The m:action or m:function element to read.
/// Post-Condition: Any - The node after the m:action or m:function element if it was read by this method.
/// XmlNodeType.Element m:action|m:function - The m:action or m:function element to read if it was not read by this method.
/// </remarks>
private bool TryReadOperation(IODataAtomReaderEntryState entryState)
{
Debug.Assert(entryState != null, "entryState != null");
this.XmlReader.AssertNotBuffering();
this.AssertXmlCondition(XmlNodeType.Element);
Debug.Assert(
this.XmlReader.NamespaceURI == AtomConstants.ODataMetadataNamespace,
"The XML reader must be on a metadata (m:*) element for this method to work.");
bool isAction = false;
if (this.XmlReader.LocalNameEquals(this.ODataActionElementName))
{
// m:action
isAction = true;
}
else if (!this.XmlReader.LocalNameEquals(this.ODataFunctionElementName))
{
// not an m:function either
return false;
}
ODataOperation operation;
if (isAction)
{
operation = new ODataAction();
entryState.Entry.AddAction((ODataAction)operation);
}
else
{
operation = new ODataFunction();
entryState.Entry.AddFunction((ODataFunction)operation);
}
string operationName = this.XmlReader.LocalName; // for error reporting
while (this.XmlReader.MoveToNextAttribute())
{
if (this.XmlReader.NamespaceEquals(this.EmptyNamespace))
{
string attributeValue = this.XmlReader.Value;
if (this.XmlReader.LocalNameEquals(this.ODataOperationMetadataAttribute))
{
// For metadata, if the URI is relative we don't attempt to make it absolute using the service
// base URI, because the ODataOperation metadata URI is relative to $metadata.
operation.Metadata = this.ProcessUriFromPayload(attributeValue, this.XmlReader.XmlBaseUri, /*makeAbsolute*/ false);
}
else if (this.XmlReader.LocalNameEquals(this.ODataOperationTargetAttribute))
{
operation.Target = this.ProcessUriFromPayload(attributeValue, this.XmlReader.XmlBaseUri);
}
else if (this.XmlReader.LocalNameEquals(this.ODataOperationTitleAttribute))
{
operation.Title = this.XmlReader.Value;
}
// skip unknown attributes
}
}
if (operation.Metadata == null)
{
throw new ODataException(ODataErrorStrings.ODataAtomEntryAndFeedDeserializer_OperationMissingMetadataAttribute(operationName));
}
if (operation.Target == null)
{
throw new ODataException(ODataErrorStrings.ODataAtomEntryAndFeedDeserializer_OperationMissingTargetAttribute(operationName));
}
// skip the content of m:action/m:function
this.XmlReader.Skip();
return true;
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:82,代码来源:ODataAtomEntryAndFeedDeserializer.cs
示例11: AddDuplicateAction
public void AddDuplicateAction()
{
var action = new ODataAction() { Metadata = new Uri("http://odata.org/metadata"), Target = new Uri("http://odata.org/target"), Title = "TestAction", };
this.odataEntry.AddAction(action);
this.odataEntry.AddAction(action);
this.odataEntry.Actions.Count().Should().Be(1);
this.odataEntry.Actions.First().Should().Be(action);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:8,代码来源:ODataEntryTests.cs
示例12: AdvertiseServiceAction
public bool AdvertiseServiceAction(DataServiceOperationContext operationContext, ServiceAction serviceAction, object resourceInstance, bool resourceInstanceInFeed, ref ODataAction actionToSerialize)
{
throw new NotImplementedException();
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:4,代码来源:TestActionProvider.cs
示例13: CheckForUnmodifiedTarget
internal void CheckForUnmodifiedTarget(ODataAction action, Func<Uri> computeOriginalTarget)
{
if (!this.interpreter.ShouldIncludeOperationMetadata(PayloadMetadataKind.Operation.Target, () => !ReferenceEquals(action.Target, computeOriginalTarget())))
{
action.Target = null;
}
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:7,代码来源:PayloadMetadataPropertyManager.cs
示例14: CheckForUnmodifiedTitle
internal void CheckForUnmodifiedTitle(ODataAction action, string originalTitle)
{
if (!this.interpreter.ShouldIncludeOperationMetadata(PayloadMetadataKind.Operation.Title, () => action.Title != originalTitle))
{
action.Title = null;
}
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:7,代码来源:PayloadMetadataPropertyManager.cs
示例15: SetTarget
internal void SetTarget(ODataAction action, bool isAlwaysAvailable, Func<Uri> computeTarget)
{
Debug.Assert(action != null, "action != null");
if (!isAlwaysAvailable || this.interpreter.ShouldIncludeOperationMetadata(PayloadMetadataKind.Operation.Target, () => false))
{
Debug.Assert(computeTarget != null, "computeTarget != null");
action.Target = computeTarget();
}
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:9,代码来源:PayloadMetadataPropertyManager.cs
示例16: ValidateOperationShouldThrowWhenOperationMetadataIsNull
public void ValidateOperationShouldThrowWhenOperationMetadataIsNull()
{
ODataOperation operation = new ODataAction();
Action action = () => ODataJsonLightValidationUtils.ValidateOperation(metadataDocumentUri, operation);
action.ShouldThrow<ODataException>().WithMessage(ErrorStrings.ValidationUtils_ActionsAndFunctionsMustSpecifyMetadata(operation.GetType().Name));
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:6,代码来源:ODataJsonLightValidationUtilsTests.cs
示例17: CreateODataOperation
private static ODataOperation CreateODataOperation(IEdmOperation operation, ProcedureLinkBuilder builder, EntityInstanceContext entityInstanceContext)
{
Contract.Assert(operation != null);
Contract.Assert(builder != null);
Contract.Assert(entityInstanceContext != null);
ODataMetadataLevel metadataLevel = entityInstanceContext.SerializerContext.MetadataLevel;
IEdmModel model = entityInstanceContext.EdmModel;
if (ShouldOmitOperation(operation, builder, metadataLevel))
{
return null;
}
Uri target = builder.BuildLink(entityInstanceContext);
if (target == null)
{
return null;
}
Uri baseUri = new Uri(entityInstanceContext.Url.CreateODataLink(new MetadataPathSegment()));
Uri metadata = new Uri(baseUri, "#" + CreateMetadataFragment(operation));
ODataOperation odataOperation;
if (operation is IEdmAction)
{
odataOperation = new ODataAction();
}
else
{
odataOperation = new ODataFunction();
}
odataOperation.Metadata = metadata;
// Always omit the title in minimal/no metadata modes.
if (metadataLevel == ODataMetadataLevel.FullMetadata)
{
EmitTitle(model, operation, odataOperation);
}
// Omit the target in minimal/no metadata modes unless it doesn't follow conventions.
if (!builder.FollowsConventions || metadataLevel == ODataMetadataLevel.FullMetadata)
{
odataOperation.Target = target;
}
return odataOperation;
}
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:48,代码来源:ODataEntityTypeSerializer.cs
示例18: CreateEntry_Calls_CreateODataActions
public void CreateEntry_Calls_CreateODataActions()
{
// Arrange
ODataAction[] actions = new ODataAction[] { new ODataAction(), new ODataAction() };
EntityInstanceContext entityInstanceContext = new EntityInstanceContext();
Mock<ODataEntityTypeSerializer> serializer = new Mock<ODataEntityTypeSerializer>(_serializer.EdmType, new DefaultODataSerializerProvider());
serializer.CallBase = true;
serializer.Setup(s => s.CreateODataActions(entityInstanceContext, _writeContext)).Returns(actions).Verifiable();
serializer.Setup(s => s.CreateStructuralPropertyBag(entityInstanceContext, _writeContext));
// Act
ODataEntry entry = serializer.Object.CreateEntry(entityInstanceContext, _writeContext);
// Assert
serializer.Verify();
Assert.Same(actions, entry.Actions);
}
开发者ID:balajivasudevan,项目名称:aspnetwebstack,代码行数:18,代码来源:ODataEntityTypeSerializerTests.cs
示例19: ActionAndFunctionTest
public void ActionAndFunctionTest()
{
// <m:action Metadata=URI title?="title" target=URI />
Uri actionMetadata = new Uri("http://odata.org/test/$metadata#defaultAction");
Uri actionMetadata2 = new Uri("#action escaped relative metadata", UriKind.Relative);
Uri actionMetadata3 = new Uri("../#action escaped relative metadata", UriKind.Relative);
string actionTitle = "Default Action";
Uri actionTarget = new Uri("http://odata.org/defaultActionTarget");
Uri actionTarget2 = new Uri("http://odata.org/defaultActionTarget2");
ODataAction action_r1_t1 = new ODataAction() { Metadata = actionMetadata, Title = actionTitle, Target = actionTarget };
ODataAction action_r1_t2 = new ODataAction() { Metadata = actionMetadata, Title = actionTitle, Target = actionTarget2 };
ODataAction action_r2_t1 = new ODataAction() { Metadata = actionMetadata2, Title = actionTitle, Target = actionTarget };
ODataAction action_r3_t1 = new ODataAction() { Metadata = actionMetadata3, Title = actionTitle, Target = actionTarget };
Uri functionMetadata = new Uri("http://odata.org/test/$metadata#defaultFunction");
Uri functionMetadata2 = new Uri("#function escaped relative metadata", UriKind.Relative);
Uri functionMetadata3 = new Uri("\\#function escaped relative metadata", UriKind.Relative);
string functionTitle = "Default Function";
Uri functionTarget = new Uri("http://odata.org/defaultFunctionTarget");
Uri functionTarget2 = new Uri("http://odata.org/defaultFunctionTarget2");
ODataFunction function_r1_t1 = new ODataFunction() { Metadata = functionMetadata, Title = functionTitle, Target = functionTarget };
ODataFunction function_r1_t2 = new ODataFunction() { Metadata = functionMetadata, Title = functionTitle, Target = functionTarget2 };
ODataFunction function_r2_t1 = new ODataFunction() { Metadata = functionMetadata2, Title = functionTitle, Target = functionTarget };
ODataFunction function_r3_t1 = new ODataFunction() { Metadata = functionMetadata3, Title = functionTitle, Target = functionTarget };
var actionCases = new[]
{
new {
ODataActions = new ODataAction[] { action_r1_t1 },
Atom = GetAtom(action_r1_t1),
JsonLight = GetJsonLightForRelGroup(action_r1_t1),
},
new {
ODataActions = new ODataAction[] { action_r1_t1, action_r1_t2 },
Atom = GetAtom(action_r1_t1) + GetAtom(action_r1_t2),
JsonLight = GetJsonLightForRelGroup(action_r1_t1, action_r1_t2),
},
new {
ODataActions = new ODataAction[] { action_r1_t1, action_r2_t1 },
Atom = GetAtom(action_r1_t1) + GetAtom(action_r2_t1),
JsonLight = GetJsonLightForRelGroup(action_r1_t1) + "," + GetJsonLightForRelGroup(action_r2_t1),
},
new {
ODataActions = new ODataAction[] { action_r1_t1, action_r2_t1, action_r1_t2 },
Atom = GetAtom(action_r1_t1) + GetAtom(action_r2_t1) + GetAtom(action_r1_t2),
JsonLight = GetJsonLightForRelGroup(action_r1_t1, action_r1_t2) + "," + GetJsonLightForRelGroup(action_r2_t1),
},
new {
ODataActions = new ODataAction[] { action_r3_t1 },
Atom = GetAtom(action_r3_t1),
JsonLight = GetJsonLightForRelGroup(action_r3_t1),
},
};
var functionCases = new[]
{
new {
ODataFunctions = new ODataFunction[] { function_r1_t1 },
Atom = GetAtom(function_r1_t1),
JsonLight = GetJsonLightForRelGroup(function_r1_t1),
},
new {
ODataFunctions = new ODataFunction[] { function_r1_t1, function_r1_t2 },
Atom = GetAtom(function_r1_t1) + GetAtom(function_r1_t2),
JsonLight = GetJsonLightForRelGroup(function_r1_t1, function_r1_t2),
},
new {
ODataFunctions = new ODataFunction[] { function_r1_t1, function_r2_t1 },
Atom = GetAtom(function_r1_t1) + GetAtom(function_r2_t1),
JsonLight = GetJsonLightForRelGroup(function_r1_t1) + "," + GetJsonLightForRelGroup(function_r2_t1),
},
new {
ODataFunctions = new ODataFunction[] { function_r1_t1, function_r2_t1, function_r1_t2 },
Atom = GetAtom(function_r1_t1) + GetAtom(function_r2_t1) + GetAtom(function_r1_t2),
JsonLight = GetJsonLightForRelGroup(function_r1_t1, function_r1_t2) + "," + GetJsonLightForRelGroup(function_r2_t1),
},
new {
ODataFunctions = new ODataFunction[] { function_r3_t1 },
Atom = GetAtom(function_r3_t1),
JsonLight = GetJsonLightForRelGroup(function_r3_t1),
},
};
var queryResults =
from actionCase in actionCases
from functionCase in functionCases
select new
{
actionCase.ODataActions,
functionCase.ODataFunctions,
Atom = string.Concat(actionCase.Atom, functionCase.Atom),
JsonLight = string.Join(",", new[] { actionCase.JsonLight, functionCase.JsonLight }.Where(x => x != null))
};
EdmModel model = new EdmModel();
EdmEntityType edmEntityTypeCustomer = model.EntityType("Customer", "TestModel");
EdmEntityContainer edmEntityContainer = model.EntityContainer("DefaultContainer","TestModel" );
//.........这里部分代码省略.........
开发者ID:AlineGuan,项目名称:odata.net,代码行数:101,代码来源:WriterActionAndFunctionTests.cs
示例20: CreateStructuralPropertyBag_Calls_CreateStructuralProperty_ForAllStructuralProperties
public void CreateStructuralPropertyBag_Calls_CreateStructuralProperty_ForAllStructuralProperties()
{
// Arrange
var instance = new object();
IEdmStructuralProperty[] structuralProperties = new[] { new Mock<IEdmStructuralProperty>().Object, new Mock<IEdmStructuralProperty>().Object };
ODataProperty[] oDataProperties = new[] { new ODataProperty(), new ODataProperty() };
ODataAction[] actions = new ODataAction[] { new ODataAction(), new ODataAction() };
EntityInstanceContext entityInstanceContext = new EntityInstanceContext { EntityInstance = instance };
Mock<IEdmEntityType> entityType = new Mock<IEdmEntityType>();
entityType.Setup(e => e.DeclaredProperties).Returns(structuralProperties);
Mock<ODataEntityTypeSerializer> serializer = new Mock<ODataEntityTypeSerializer>(
new EdmEntityTypeReference(entityType.Object, isNullable: false),
new DefaultODataSerializerProvider());
serializer.CallBase = true;
serializer.Setup(s => s.CreateStructuralProperty(structuralProperties[0], instance, _writeContext)).Returns(oDataProperties[0]).Verifiable();
serializer.Setup(s => s.CreateStructuralProperty(structuralProperties[1], instance, _writeContext)).Returns(oDataProperties[1]).Verifiable();
// Act
IEnumerable<ODataProperty> propertyValues = serializer.Object.CreateStructuralPropertyBag(entityInstanceContext, _writeContext);
// Assert
serializer.Verify();
}
开发者ID:balajivasudevan,项目名称:aspnetwebstack,代码行数:24,代码来源:ODataEntityTypeSerializerTests.cs
注:本文中的ODataAction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论