private void VerifyKey(EdmxTestCase.TestNode entityTypeNode, OdcmType odcmEntityType) { var entityTypeDescendants = entityTypeNode.Element.Descendants(); var properties = entityTypeDescendants.Where(x => x.Name.LocalName == "PropertyRef"); var keyCount = properties.Count(); odcmEntityType.As <OdcmEntityClass>().Key .Count().Should().Be(keyCount, "because the Key of an OdcmEntityClass should have the same number of OdcmProperties as there are properties in the entity type key"); odcmEntityType.As <OdcmEntityClass>().Key .Count(key => properties.Any(x => x.GetName() == key.CanonicalName())) .Should().Be(keyCount, "because the Key of an OdcmEntityClass should have the corresponding OdcmProperties as in the entity type key"); }
private OdcmType VerifyEntityType(OdcmModel odcmModel, EdmxTestCase.TestNode entityTypeNode) { OdcmType odcmEntityType; odcmModel.TryResolveType(entityTypeNode.Name, entityTypeNode.Namespace, out odcmEntityType) .Should() .BeTrue("because an entity type in the schema should result in an OdcmType"); odcmEntityType .Should() .BeAssignableTo <OdcmEntityClass>("because entity types should result in an OdcmClass"); return(odcmEntityType); }
public EdmxTestCase AddBoundFunction(string functionKey, string boundEntityTypeKey, XElement schemaElement = null, Action <EdmxTestCase, XElement> config = null) { var boundEntityType = _testObjectMap[boundEntityTypeKey]; var schema = _testObjectMap[Keys.Schema]; if (schemaElement != null) { var functionNamespace = schemaElement.Attribute("Namespace").Value; schema = new EdmxTestCase.TestNode(functionNamespace, string.Empty, schemaElement); } schema.Element.Add(Any.Csdl.Function(Any.Csdl.RandomPrimitiveType(), function => { var testNode = new TestNode(schema.Namespace, function); _testObjectMap.Add(functionKey, testNode); function.AddAttribute("IsBound", true); function.Add(Any.Csdl.Parameter(boundEntityType.FullName())); foreach ( var parameter in Any.Sequence(i => Any.Csdl.Parameter(Any.Csdl.RandomPrimitiveType()), Any.Int(1, 3))) { function.Add(parameter); } if (config != null) { config(this, function); } })); if (schemaElement != null) { var dataServices = _testObjectMap[Keys.DataServices]; dataServices.Element.Add(schemaElement); } return(this); }