Exemplo n.º 1
0
        public void GetPrimitiveFromCLRType_KnownType()
        {
            ResourceType resourceType = typeMap.GetPrimitive(knownPrimitiveType);

            VerifyTestPrimitiveResourceType(resourceType);
        }
Exemplo n.º 2
0
        public void ValidatePrimitiveResourceTypeMapConstructorHasAllBuiltInTypes()
        {
            PrimitiveResourceTypeMap mapping = new PrimitiveResourceTypeMap();

            string edmBinaryTypeName                  = "Binary";
            string edmBooleanTypeName                 = "Boolean";
            string edmByteTypeName                    = "Byte";
            string edmDateTimeOffsetName              = "DateTimeOffset";
            string edmDecimalTypeName                 = "Decimal";
            string edmDoubleTypeName                  = "Double";
            string edmGuidTypeName                    = "Guid";
            string edmSingleTypeName                  = "Single";
            string edmSByteTypeName                   = "SByte";
            string edmInt16TypeName                   = "Int16";
            string edmInt32TypeName                   = "Int32";
            string edmInt64TypeName                   = "Int64";
            string edmStringTypeName                  = "String";
            string edmStreamTypeName                  = "Stream";
            string edmGeographyTypeName               = "Geography";
            string edmPointTypeName                   = "GeographyPoint";
            string edmLineStringTypeName              = "GeographyLineString";
            string edmPolygonTypeName                 = "GeographyPolygon";
            string edmGeographyCollectionTypeName     = "GeographyCollection";
            string edmMultiLineStringTypeName         = "GeographyMultiLineString";
            string edmMultiPointTypeName              = "GeographyMultiPoint";
            string edmMultiPolygonTypeName            = "GeographyMultiPolygon";
            string edmGeometryTypeName                = "Geometry";
            string edmGeometryPointTypeName           = "GeometryPoint";
            string edmGeometryLineStringTypeName      = "GeometryLineString";
            string edmGeometryPolygonTypeName         = "GeometryPolygon";
            string edmGeometryCollectionTypeName      = "GeometryCollection";
            string edmGeometryMultiLineStringTypeName = "GeometryMultiLineString";
            string edmGeometryMultiPointTypeName      = "GeometryMultiPoint";
            string edmGeometryMultiPolygonTypeName    = "GeometryMultiPolygon";
            string edmDurationTypeName                = "Duration";

            KeyValuePair <Type, string>[] expectedBuiltInTypes =
                new KeyValuePair <Type, string>[]
            {
                new KeyValuePair <Type, string>(typeof(string), edmStringTypeName),
                new KeyValuePair <Type, string>(typeof(Boolean), edmBooleanTypeName),
                new KeyValuePair <Type, string>(typeof(Boolean?), edmBooleanTypeName),
                new KeyValuePair <Type, string>(typeof(Byte), edmByteTypeName),
                new KeyValuePair <Type, string>(typeof(Byte?), edmByteTypeName),
                new KeyValuePair <Type, string>(typeof(DateTime), edmDateTimeOffsetName),
                new KeyValuePair <Type, string>(typeof(DateTime?), edmDateTimeOffsetName),
                new KeyValuePair <Type, string>(typeof(DateTimeOffset), edmDateTimeOffsetName),
                new KeyValuePair <Type, string>(typeof(DateTimeOffset?), edmDateTimeOffsetName),
                new KeyValuePair <Type, string>(typeof(Decimal), edmDecimalTypeName),
                new KeyValuePair <Type, string>(typeof(Decimal?), edmDecimalTypeName),
                new KeyValuePair <Type, string>(typeof(Double), edmDoubleTypeName),
                new KeyValuePair <Type, string>(typeof(Double?), edmDoubleTypeName),
                new KeyValuePair <Type, string>(typeof(Guid), edmGuidTypeName),
                new KeyValuePair <Type, string>(typeof(Guid?), edmGuidTypeName),
                new KeyValuePair <Type, string>(typeof(Int16), edmInt16TypeName),
                new KeyValuePair <Type, string>(typeof(Int16?), edmInt16TypeName),
                new KeyValuePair <Type, string>(typeof(Int32), edmInt32TypeName),
                new KeyValuePair <Type, string>(typeof(Int32?), edmInt32TypeName),
                new KeyValuePair <Type, string>(typeof(Int64), edmInt64TypeName),
                new KeyValuePair <Type, string>(typeof(Int64?), edmInt64TypeName),
                new KeyValuePair <Type, string>(typeof(SByte), edmSByteTypeName),
                new KeyValuePair <Type, string>(typeof(SByte?), edmSByteTypeName),
                new KeyValuePair <Type, string>(typeof(Single), edmSingleTypeName),
                new KeyValuePair <Type, string>(typeof(Single?), edmSingleTypeName),
                new KeyValuePair <Type, string>(typeof(byte[]), edmBinaryTypeName),
                new KeyValuePair <Type, string>(typeof(Stream), edmStreamTypeName),
                new KeyValuePair <Type, string>(typeof(TimeSpan), edmDurationTypeName),
                new KeyValuePair <Type, string>(typeof(TimeSpan?), edmDurationTypeName),
                new KeyValuePair <Type, string>(typeof(Geography), edmGeographyTypeName),
                new KeyValuePair <Type, string>(typeof(GeographyPoint), edmPointTypeName),
                new KeyValuePair <Type, string>(typeof(GeographyLineString), edmLineStringTypeName),
                new KeyValuePair <Type, string>(typeof(GeographyPolygon), edmPolygonTypeName),
                new KeyValuePair <Type, string>(typeof(GeographyCollection), edmGeographyCollectionTypeName),
                new KeyValuePair <Type, string>(typeof(GeographyMultiPoint), edmMultiPointTypeName),
                new KeyValuePair <Type, string>(typeof(GeographyMultiLineString), edmMultiLineStringTypeName),
                new KeyValuePair <Type, string>(typeof(GeographyMultiPolygon), edmMultiPolygonTypeName),
                new KeyValuePair <Type, string>(typeof(Geometry), edmGeometryTypeName),
                new KeyValuePair <Type, string>(typeof(GeometryPoint), edmGeometryPointTypeName),
                new KeyValuePair <Type, string>(typeof(GeometryLineString), edmGeometryLineStringTypeName),
                new KeyValuePair <Type, string>(typeof(GeometryPolygon), edmGeometryPolygonTypeName),
                new KeyValuePair <Type, string>(typeof(GeometryCollection), edmGeometryCollectionTypeName),
                new KeyValuePair <Type, string>(typeof(GeometryMultiPoint), edmGeometryMultiPointTypeName),
                new KeyValuePair <Type, string>(typeof(GeometryMultiLineString), edmGeometryMultiLineStringTypeName),
                new KeyValuePair <Type, string>(typeof(GeometryMultiPolygon), edmGeometryMultiPolygonTypeName),
                new KeyValuePair <Type, string>(typeof(XElement), edmStringTypeName),
                new KeyValuePair <Type, string>(typeof(Binary), edmBinaryTypeName),
            };

            Assert.AreEqual(expectedBuiltInTypes.Length, mapping.AllPrimitives.Length, "AllPrimitives contains a different number of types than expected for the mapping provided by the default constructor.");

            foreach (KeyValuePair <Type, string> expectedType in expectedBuiltInTypes)
            {
                ResourceType resourceType = mapping.GetPrimitive(expectedType.Key);
                PrimitiveResourceTypeMapTests.VerifyPrimitiveResourceType(resourceType, expectedType.Key, expectedType.Value);
            }
        }