private static KeyValuePair <Type, string>[] BuildTypeMap(Type[] types) { Assert.IsTrue(types != null && types.Length > 0, "Expected a non-null and non-empty set of types to build the type map for the test."); KeyValuePair <Type, string>[] mappedPrimitiveTypes = new KeyValuePair <Type, string> [types.Length]; for (int i = 0; i < types.Length; i++) { mappedPrimitiveTypes[i] = new KeyValuePair <Type, string>(types[i], ProviderMemberSimulator.GetEdmTypeName(types[i])); } return(mappedPrimitiveTypes); }
private static void VerifyResourceProperty(string expectedPropertyName, Type expectedPropertyType, ResourceProperty actualResourceProperty) { ResourcePropertyKind expectedPropertyKind = ResourcePropertyKind.Primitive; if (expectedPropertyName == ProviderMemberSimulator.KeyPropertyName) { expectedPropertyKind |= ResourcePropertyKind.Key; } string expectedMimeType = ProviderMemberSimulator.IsMimeType(expectedPropertyName) ? ProviderMemberSimulator.SimulatedMimeType : null; Assert.AreEqual(expectedPropertyKind, actualResourceProperty.Kind, "Expected ResourceProperty {0} to be a primitive.", expectedPropertyName); Assert.AreEqual(expectedPropertyType, actualResourceProperty.Type, "ResourceProperty.Type is not the expected type."); Assert.AreEqual(expectedMimeType, actualResourceProperty.MimeType, "Expected ResourceProperty {0} to have the simulated MimeType.", expectedPropertyName); }
public void VerifyPopulateMemberMetadataFailsOnEnumPropertyOnEntityType() { Type entityClrType = typeof(TestEntityTypeWithEnum); Type[] primitiveTypes = new Type[] { typeof(string) }; PrimitiveResourceTypeMap typeMap; ResourceType entityResourceType; ProviderMetadataSimulator workspace; SetupTestMetadata(entityClrType, primitiveTypes, out entityResourceType, out workspace, out typeMap); Action test = () => ObjectContextServiceProvider.PopulateMemberMetadata(new ResourceTypeCacheItem(entityResourceType), workspace, null, typeMap); test.ShouldThrow <NotSupportedException>().WithMessage(Strings.ObjectContext_PrimitiveTypeNotSupported("EnumProperty", entityClrType.Name, ProviderMemberSimulator.GetEdmTypeName(typeof(Enum)))); }