// protected methods
        /// <summary>
        /// Reconfigures the specified serializer by applying this attribute to it.
        /// </summary>
        /// <param name="serializer">The serializer.</param>
        /// <returns>A reconfigured serializer.</returns>
        protected override IBsonSerializer Apply(IBsonSerializer serializer)
        {
            var representationConfigurable = serializer as IRepresentationConfigurable;

            if (representationConfigurable != null)
            {
                var reconfiguredSerializer = representationConfigurable.WithRepresentation(_representation);

                var converterConfigurable = reconfiguredSerializer as IRepresentationConverterConfigurable;
                if (converterConfigurable != null)
                {
                    var converter = new RepresentationConverter(_allowOverflow, _allowTruncation);
                    reconfiguredSerializer = converterConfigurable.WithConverter(converter);
                }

                return(reconfiguredSerializer);
            }

            // for backward compatibility representations of Array and Document are mapped to DictionaryRepresentations if possible
            var dictionaryRepresentationConfigurable = serializer as IDictionaryRepresentationConfigurable;

            if (dictionaryRepresentationConfigurable != null)
            {
                if (_representation == BsonType.Array || _representation == BsonType.Document)
                {
                    var dictionaryRepresentation = (_representation == BsonType.Array) ? DictionaryRepresentation.ArrayOfArrays : DictionaryRepresentation.Document;
                    return(dictionaryRepresentationConfigurable.WithDictionaryRepresentation(dictionaryRepresentation));
                }
            }

            return(base.Apply(serializer));
        }
Example #2
0
        public SubFileParameter(SubFileParameterBuilder subFileParameterBuilder, RepresentationConverter projection)
        {
            this.StartAddress      = subFileParameterBuilder.startAddress;
            this.IndexStartAddress = subFileParameterBuilder.indexStartAddress;
            this.SubFileSize       = subFileParameterBuilder.subFileSize;
            this.BaseZoomLevel     = subFileParameterBuilder.baseZoomLevel;
            this.ZoomLevelMin      = subFileParameterBuilder.zoomLevelMin;
            this.ZoomLevelMax      = subFileParameterBuilder.zoomLevelMax;

            // calculate the XY numbers of the boundary tiles in this sub-file
            var tile1 = projection.GeoPointToTile(subFileParameterBuilder.boundingBox.point1, this.BaseZoomLevel);
            var tile2 = projection.GeoPointToTile(subFileParameterBuilder.boundingBox.point2, this.BaseZoomLevel);

            this.BoundaryTileLeft   = tile1.TileX;
            this.BoundaryTileBottom = tile1.TileY;
            this.BoundaryTileRight  = tile2.TileX;
            this.BoundaryTileTop    = tile2.TileY;

            // calculate the horizontal and vertical amount of blocks in this sub-file
            this.BlocksWidth  = this.BoundaryTileRight - this.BoundaryTileLeft + 1;
            this.BlocksHeight = this.BoundaryTileBottom - this.BoundaryTileTop + 1;

            // calculate the total amount of blocks in this sub-file
            this.NumberOfBlocks = this.BlocksWidth * this.BlocksHeight;

            this.IndexEndAddress = this.IndexStartAddress + this.NumberOfBlocks * BytesPerIndexEntry;
        }
Example #3
0
        public void TestAllowOverflowTrue()
        {
            var converter = new RepresentationConverter(true, false);

            // need variables to get some conversions to happen at runtime instead of compile time
            var doubleMaxValue = double.MaxValue;
            var doubleMinValue = double.MinValue;
            var floatMaxValue  = float.MaxValue;
            var floatMinValue  = float.MinValue;
            var intMaxValue    = int.MaxValue;
            var intMinValue    = int.MinValue;
            var longMaxValue   = long.MaxValue;
            var longMinValue   = long.MinValue;
            var uintMaxValue   = uint.MaxValue;
            var ulongMaxValue  = ulong.MaxValue;

            Assert.Equal(unchecked ((short)doubleMaxValue), converter.ToInt16(double.MaxValue));
            Assert.Equal(unchecked ((short)doubleMinValue), converter.ToInt16(double.MinValue));
            Assert.Equal(unchecked ((short)intMaxValue), converter.ToInt16(int.MaxValue));
            Assert.Equal(unchecked ((short)intMinValue), converter.ToInt16(int.MinValue));
            Assert.Equal(unchecked ((short)longMaxValue), converter.ToInt16(long.MaxValue));
            Assert.Equal(unchecked ((short)longMinValue), converter.ToInt16(long.MinValue));

            Assert.Equal(unchecked ((int)doubleMaxValue), converter.ToInt32(double.MaxValue));
            Assert.Equal(unchecked ((int)doubleMinValue), converter.ToInt32(double.MinValue));
            Assert.Equal(unchecked ((int)floatMaxValue), converter.ToInt32(float.MaxValue));
            Assert.Equal(unchecked ((int)floatMinValue), converter.ToInt32(float.MinValue));
            Assert.Equal(unchecked ((int)longMaxValue), converter.ToInt32(long.MaxValue));
            Assert.Equal(unchecked ((int)longMinValue), converter.ToInt32(long.MinValue));
            Assert.Equal(unchecked ((int)uintMaxValue), converter.ToInt32(uint.MaxValue));
            Assert.Equal(unchecked ((int)ulongMaxValue), converter.ToInt32(ulong.MaxValue));

            Assert.Equal(unchecked ((long)doubleMaxValue), converter.ToInt64(double.MaxValue));
            Assert.Equal(unchecked ((long)doubleMinValue), converter.ToInt64(double.MinValue));
            Assert.Equal(unchecked ((long)floatMaxValue), converter.ToInt64(float.MaxValue));
            Assert.Equal(unchecked ((long)floatMinValue), converter.ToInt64(float.MinValue));
            Assert.Equal(unchecked ((long)ulongMaxValue), converter.ToInt64(ulong.MaxValue));

            Assert.Equal(unchecked ((float)(doubleMaxValue / 10.0)), converter.ToSingle(double.MaxValue / 10.0));
            Assert.Equal(unchecked ((float)(doubleMinValue / 10.0)), converter.ToSingle(double.MinValue / 10.0));

            Assert.Equal(unchecked ((ushort)doubleMaxValue), converter.ToUInt16(double.MaxValue));
            Assert.Equal(unchecked ((ushort)doubleMinValue), converter.ToUInt16(double.MinValue));
            Assert.Equal(unchecked ((ushort)intMaxValue), converter.ToUInt16(int.MaxValue));
            Assert.Equal(unchecked ((ushort)intMinValue), converter.ToUInt16(int.MinValue));
            Assert.Equal(unchecked ((ushort)longMaxValue), converter.ToUInt16(long.MaxValue));
            Assert.Equal(unchecked ((ushort)longMinValue), converter.ToUInt16(long.MinValue));

            Assert.Equal(unchecked ((uint)doubleMaxValue), converter.ToUInt32(double.MaxValue));
            Assert.Equal(unchecked ((uint)doubleMinValue), converter.ToUInt32(double.MinValue));
            Assert.Equal(unchecked ((uint)intMinValue), converter.ToUInt32(int.MinValue));
            Assert.Equal(unchecked ((uint)longMaxValue), converter.ToUInt32(long.MaxValue));
            Assert.Equal(unchecked ((uint)longMinValue), converter.ToUInt32(long.MinValue));

            Assert.Equal(unchecked ((ulong)doubleMaxValue), converter.ToUInt64(double.MaxValue));
            Assert.Equal(unchecked ((ulong)doubleMinValue), converter.ToUInt64(double.MinValue));
            Assert.Equal(unchecked ((ulong)intMinValue), converter.ToUInt64(int.MinValue));
            Assert.Equal(unchecked ((ulong)longMinValue), converter.ToUInt64(long.MinValue));
        }
Example #4
0
 /// <summary>
 /// Returns a serializer that has been reconfigured with the specified item serializer.
 /// </summary>
 /// <param name="converter">The converter.</param>
 /// <returns>The reconfigured serializer.</returns>
 public Decimal128Serializer WithConverter(RepresentationConverter converter)
 {
     if (converter == _converter)
     {
         return(this);
     }
     else
     {
         return(new Decimal128Serializer(_representation, converter));
     }
 }
Example #5
0
 /// <summary>
 /// Returns a serializer that has been reconfigured with the specified item serializer.
 /// </summary>
 /// <param name="converter">The converter.</param>
 /// <returns>The reconfigured serializer.</returns>
 public UInt16Serializer WithConverter(RepresentationConverter converter)
 {
     if (converter == _converter)
     {
         return(this);
     }
     else
     {
         return(new UInt16Serializer(_representation, converter));
     }
 }
Example #6
0
        public MapElement(RepresentationConverter projection, Tile baseTile, Vector correctionVector, Node node)
        {
            Tags      = node.Tags;
            IsClosed  = null;
            this.Tile = baseTile;

            WayGeometry = null;
            var mapPoint = (Point)projection.GeoPointToMappoint(node.Position, baseTile.ZoomFactor);

            Position           = mapPoint + correctionVector;
            RenderInstructions = new List <RenderInstruction>();
        }
Example #7
0
        public MapTile(RepresentationConverter projection, Tile baseTile, Brush brush = null)
        {
            this.projection = projection;
            this.baseTile   = baseTile;
            this.Width      = baseTile.TileSize;
            this.Height     = baseTile.TileSize;

            InitializeComponent();
            this.ClipToBounds = true;

            this.Background = brush;
        }
Example #8
0
        public void TestAllowTruncationFalse()
        {
            var converter = new RepresentationConverter(false, false);

            Assert.Throws <TruncationException>(() => converter.ToDouble(long.MaxValue));
            Assert.Throws <TruncationException>(() => converter.ToDouble(ulong.MaxValue));
            Assert.Throws <TruncationException>(() => converter.ToInt16((double)1.5));
            Assert.Throws <TruncationException>(() => converter.ToInt32((double)1.5));
            Assert.Throws <TruncationException>(() => converter.ToInt32((float)1.5F));
            Assert.Throws <TruncationException>(() => converter.ToInt64((double)1.5));
            Assert.Throws <TruncationException>(() => converter.ToInt64((float)1.5F));
            Assert.Throws <TruncationException>(() => converter.ToSingle(double.Epsilon));
            Assert.Throws <TruncationException>(() => converter.ToUInt16((double)1.5));
            Assert.Throws <TruncationException>(() => converter.ToUInt32((double)1.5));
            Assert.Throws <TruncationException>(() => converter.ToUInt64((double)1.5));
        }
Example #9
0
        public void TestAllowTruncationTrue()
        {
            var converter = new RepresentationConverter(false, true);

            Assert.Equal((double)long.MaxValue, converter.ToDouble(long.MaxValue));
            Assert.Equal((double)ulong.MaxValue, converter.ToDouble(ulong.MaxValue));
            Assert.Equal((short)1, converter.ToInt16((double)1.5));
            Assert.Equal((int)1, converter.ToInt32((double)1.5));
            Assert.Equal((int)1, converter.ToInt32((float)1.5F));
            Assert.Equal((long)1, converter.ToInt64((double)1.5));
            Assert.Equal((long)1, converter.ToInt64((float)1.5F));
            Assert.Equal((float)0.0F, converter.ToSingle(double.Epsilon));
            Assert.Equal((ushort)1, converter.ToUInt16((double)1.5));
            Assert.Equal((uint)1, converter.ToUInt32((double)1.5));
            Assert.Equal((ulong)1, converter.ToUInt64((double)1.5));
        }
Example #10
0
        public void TestAllowOverflowFalse()
        {
            var converter = new RepresentationConverter(false, false);

            Assert.Throws <OverflowException>(() => converter.ToInt16(double.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToInt16(double.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToInt16(int.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToInt16(int.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToInt16(long.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToInt16(long.MinValue));

            Assert.Throws <OverflowException>(() => converter.ToInt32(double.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToInt32(double.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToInt32(float.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToInt32(float.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToInt32(long.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToInt32(long.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToInt32(uint.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToInt32(ulong.MaxValue));

            Assert.Throws <OverflowException>(() => converter.ToInt64(double.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToInt64(double.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToInt64(float.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToInt64(float.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToInt64(ulong.MaxValue));

            Assert.Throws <OverflowException>(() => converter.ToSingle(double.MaxValue / 10.0));
            Assert.Throws <OverflowException>(() => converter.ToSingle(double.MinValue / 10.0));

            Assert.Throws <OverflowException>(() => converter.ToUInt16(double.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt16(double.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt16(int.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt16(int.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt16(long.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt16(long.MinValue));

            Assert.Throws <OverflowException>(() => converter.ToUInt32(double.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt32(double.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt32(int.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt32(long.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt32(long.MinValue));

            Assert.Throws <OverflowException>(() => converter.ToUInt64(double.MaxValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt64(double.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt64(int.MinValue));
            Assert.Throws <OverflowException>(() => converter.ToUInt64(long.MinValue));
        }
Example #11
0
        static void Main(string[] args)
        {
            var projection = new RepresentationConverter(Projections.Mercator);

            var GeoPoint1 = new GeoPoint(45, 5);
            var mappoint1 = projection.GeoPointToMappoint(GeoPoint1, 10);
            var GeoPoint2 = projection.MappointToGeoPoint(mappoint1);
            var tile1     = projection.MappointToTile(mappoint1);
            var tile2     = projection.GeoPointToTile(GeoPoint1, 10);

            Console.WriteLine("GeoPoint1 = {0}", GeoPoint1);
            Console.WriteLine("GeoPoint2 = {0}", GeoPoint2);
            Console.WriteLine("Mappoint1 = {0}", mappoint1);
            Console.WriteLine("Tile1 = {0} {{\n\tpoint1 : {1}  \n\tpoint2 : {2}\n}}", tile1, tile1.MapPoint1, tile1.MapPoint2);
            Console.WriteLine("Tile2 = {0}", tile2);
            Console.WriteLine("Tile1 contains Mappoint1 = {0}", tile1.Contains(mappoint1));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UInt64Serializer"/> class.
        /// </summary>
        /// <param name="representation">The representation.</param>
        /// <param name="converter">The converter.</param>
        public UInt64Serializer(BsonType representation, RepresentationConverter converter)
        {
            switch (representation)
            {
            case BsonType.Double:
            case BsonType.Int32:
            case BsonType.Int64:
            case BsonType.String:
                break;

            default:
                var message = string.Format("{0} is not a valid representation for a UInt64Serializer.", representation);
                throw new ArgumentException(message);
            }

            _representation = representation;
            _converter      = converter;
        }
Example #13
0
        public MapElement(RepresentationConverter projection, Tile baseTile, Vector correctionVector, Way way)
        {
            this.Tile = baseTile;
            Tags      = way.Tags;
            IsClosed  = true;

            PathFigureCollection waySegments = new PathFigureCollection();

            foreach (var geoPointList in way.GeoPoints)
            {
                PathFigure waySegment = new PathFigure();
                waySegment.Segments = new PathSegmentCollection();
                var geoPointEnumerator = geoPointList.GetEnumerator();
                geoPointEnumerator.MoveNext();

                var mappoint = projection.GeoPointToMappoint(geoPointEnumerator.Current, baseTile.ZoomFactor);
                waySegment.StartPoint = (Point)mappoint - correctionVector;

                Point?lastPoint = null;
                while (geoPointEnumerator.MoveNext())
                {
                    mappoint  = projection.GeoPointToMappoint(geoPointEnumerator.Current, baseTile.ZoomFactor);
                    lastPoint = (Point)mappoint - correctionVector;
                    waySegment.Segments.Add(new LineSegment(lastPoint.Value, true));
                }
                waySegments.Add(waySegment);
                if (lastPoint == null || lastPoint.Value != waySegment.StartPoint)
                {
                    IsClosed = false;
                }
            }

            WayGeometry         = new PathGeometry();
            WayGeometry.Figures = waySegments;

            Point?mapPoint = way.LabelPosition == null ? (Point?)null : (Point)projection.GeoPointToMappoint(way.LabelPosition, baseTile.ZoomFactor);

            Position = mapPoint == null ? null : (mapPoint + correctionVector);

            RenderInstructions = new List <RenderInstruction>();
        }
Example #14
0
 public SubFileParameter build(RepresentationConverter projection)
 {
     return(new SubFileParameter(this, projection));
 }
Example #15
0
 // explicit interface implementations
 IBsonSerializer IRepresentationConverterConfigurable.WithConverter(RepresentationConverter converter)
 {
     return(WithConverter(converter));
 }
Example #16
0
        private static void Worker()
        {
            // Note that a class map must only be registered once(an exception will be thrown
            // if you try to register the same class map more than once).
            // Usually you call RegisterClassMap from some code path that is known to execute only once
            // (the Main method, the Application_Start event handler, etc…).
            if (!BsonClassMap.IsClassMapRegistered(typeof(TestSerializerWithOutAttributes)))
            {
                BsonClassMap.RegisterClassMap <TestSerializerWithOutAttributes>(cm =>
                {
                    // ! only read and write properties are mapped
                    // in the example cm.AutoMap is not used!
                    //cm.AutoMap();

                    // BsonId attribute
                    cm.MapIdProperty(c => c.SalesOrderId);

                    //Setting ElementName and Order
                    cm.MapProperty(c => c.Comment).SetElementName("description").SetOrder(1);

                    // Setting the default decimal serializer
                    cm.MapProperty(c => c.Salary).SetSerializer(new DecimalSerializer(BsonType.Decimal128));

                    // we have to set an object of type RepresentationConverter and pass allowTruncation 'true'
                    var rp = new RepresentationConverter(allowOverflow: false, allowTruncation: true);
                    cm.MapProperty(c => c.MongoValueTypeDouble).SetElementName("mydouble")
                    .SetSerializer(new DoubleSerializer(BsonType.Double, converter: rp));


                    //Before was .SetSerializationOptions(new DateTimeSerializationOptions { DateOnly = true });
                    // We could accomplished the same task by applying custom serializer or specfiying pre-build serialzer DateTimeSerializer
                    //cm.MapProperty(c => c.OnlyDate).SetSerializer(new OnlyDateSerializer());
                    cm.MapProperty(c => c.OnlyDate).SetSerializer(new DateTimeSerializer(dateOnly: true));
                    cm.MapProperty(c => c.LocalTime).SetSerializer(new DateTimeSerializer(DateTimeKind.Local));
                });
            }


            var p = new TestSerializerWithOutAttributes()
            {
                SalesOrderId         = 1,
                Comment              = "Test",
                OnlyDate             = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day),
                LocalTime            = DateTime.Now,
                Salary               = 120.1112223334455666m,
                MongoValueTypeDouble = 1.11122233344445556667778888999
            };
            var ws = new JsonWriterSettings
            {
                Indent = true,
            };

            ConsoleEx.WriteLine("The serialization process is controlled by using ClassMap", ConsoleColor.Cyan);
            ConsoleEx.WriteLine(p.ToJson(ws), ConsoleColor.Yellow);
            var p1 = BsonSerializer.Deserialize <TestSerializerWithOutAttributes>(p.ToJson());

            Console.WriteLine(new
            {
                p1.LocalTime.Kind,
                Value = p1.LocalTime
            });
        }
Example #17
0
        public void TestConversions()
        {
            var converter = new RepresentationConverter(false, false);

            Assert.Equal((double)1.5, converter.ToDouble((double)1.5));
            Assert.Equal((double)double.MinValue, converter.ToDouble(double.MinValue));
            Assert.Equal((double)double.MaxValue, converter.ToDouble(double.MaxValue));
            Assert.Equal((double)double.NegativeInfinity, converter.ToDouble(double.NegativeInfinity));
            Assert.Equal((double)double.PositiveInfinity, converter.ToDouble(double.PositiveInfinity));
            Assert.Equal((double)double.NaN, converter.ToDouble(double.NaN));
            Assert.Equal((double)1.5, converter.ToDouble((float)1.5F));
            Assert.Equal((double)double.MinValue, converter.ToDouble(float.MinValue));
            Assert.Equal((double)double.MaxValue, converter.ToDouble(float.MaxValue));
            Assert.Equal((double)double.NegativeInfinity, converter.ToDouble(float.NegativeInfinity));
            Assert.Equal((double)double.PositiveInfinity, converter.ToDouble(float.PositiveInfinity));
            Assert.Equal((double)double.NaN, converter.ToDouble(float.NaN));
            Assert.Equal((double)1.0, converter.ToDouble((int)1));
            Assert.Equal((double)int.MaxValue, converter.ToDouble(int.MaxValue));
            Assert.Equal((double)int.MinValue, converter.ToDouble(int.MinValue));
            Assert.Equal((double)1.0, converter.ToDouble((long)1));
            Assert.Equal((double)1.0, converter.ToDouble((short)1));
            Assert.Equal((double)short.MaxValue, converter.ToDouble(short.MaxValue));
            Assert.Equal((double)short.MinValue, converter.ToDouble(short.MinValue));
            Assert.Equal((double)1.0, converter.ToDouble((uint)1));
            Assert.Equal((double)uint.MaxValue, converter.ToDouble(uint.MaxValue));
            Assert.Equal((double)uint.MinValue, converter.ToDouble(uint.MinValue));
            Assert.Equal((double)1.0, converter.ToDouble((ulong)1));
            Assert.Equal((double)ulong.MinValue, converter.ToDouble(ulong.MinValue));
            Assert.Equal((double)1.0, converter.ToDouble((ushort)1));
            Assert.Equal((double)ushort.MaxValue, converter.ToDouble(ushort.MaxValue));
            Assert.Equal((double)ushort.MinValue, converter.ToDouble(ushort.MinValue));

            Assert.Equal((short)1, converter.ToInt16((double)1.0));
            Assert.Equal((short)1, converter.ToInt16((int)1));
            Assert.Equal((short)1, converter.ToInt16((long)1));

            Assert.Equal((int)1, converter.ToInt32((double)1.0));
            Assert.Equal((int)1, converter.ToInt32((float)1.0F));
            Assert.Equal((int)1, converter.ToInt32((int)1));
            Assert.Equal((int)int.MaxValue, converter.ToInt32(int.MaxValue));
            Assert.Equal((int)int.MinValue, converter.ToInt32(int.MinValue));
            Assert.Equal((int)1, converter.ToInt32((long)1));
            Assert.Equal((int)1, converter.ToInt32((short)1));
            Assert.Equal((int)short.MaxValue, converter.ToInt32(short.MaxValue));
            Assert.Equal((int)short.MinValue, converter.ToInt32(short.MinValue));
            Assert.Equal((int)1, converter.ToInt32((uint)1));
            Assert.Equal((int)uint.MinValue, converter.ToInt32(uint.MinValue));
            Assert.Equal((int)1, converter.ToInt32((ulong)1));
            Assert.Equal((int)ulong.MinValue, converter.ToInt32(ulong.MinValue));
            Assert.Equal((int)1, converter.ToInt32((ushort)1));
            Assert.Equal((int)ushort.MaxValue, converter.ToInt32(ushort.MaxValue));
            Assert.Equal((int)ushort.MinValue, converter.ToInt32(ushort.MinValue));

            Assert.Equal((long)1, converter.ToInt64((double)1.0));
            Assert.Equal((long)1, converter.ToInt64((float)1.0F));
            Assert.Equal((long)1, converter.ToInt64((int)1));
            Assert.Equal((long)int.MaxValue, converter.ToInt64(int.MaxValue));
            Assert.Equal((long)int.MinValue, converter.ToInt64(int.MinValue));
            Assert.Equal((long)1, converter.ToInt64((long)1));
            Assert.Equal((long)long.MaxValue, converter.ToInt64(long.MaxValue));
            Assert.Equal((long)long.MinValue, converter.ToInt64(long.MinValue));
            Assert.Equal((long)1, converter.ToInt64((short)1));
            Assert.Equal((long)short.MaxValue, converter.ToInt64(short.MaxValue));
            Assert.Equal((long)short.MinValue, converter.ToInt64(short.MinValue));
            Assert.Equal((long)1, converter.ToInt64((uint)1));
            Assert.Equal((long)uint.MaxValue, converter.ToInt64(uint.MaxValue));
            Assert.Equal((long)uint.MinValue, converter.ToInt64(uint.MinValue));
            Assert.Equal((long)1, converter.ToInt64((ulong)1));
            Assert.Equal((long)ulong.MinValue, converter.ToInt64(ulong.MinValue));
            Assert.Equal((long)1, converter.ToInt64((ushort)1));
            Assert.Equal((long)ushort.MaxValue, converter.ToInt64(ushort.MaxValue));
            Assert.Equal((long)ushort.MinValue, converter.ToInt64(ushort.MinValue));

            Assert.Equal((float)1.0F, converter.ToSingle((double)1.0));
            Assert.Equal((float)float.MinValue, converter.ToSingle(double.MinValue));
            Assert.Equal((float)float.MaxValue, converter.ToSingle(double.MaxValue));
            Assert.Equal((float)float.NegativeInfinity, converter.ToSingle(double.NegativeInfinity));
            Assert.Equal((float)float.PositiveInfinity, converter.ToSingle(double.PositiveInfinity));
            Assert.Equal((float)float.NaN, converter.ToSingle(double.NaN));
            Assert.Equal((float)1.0F, converter.ToSingle((int)1));
            Assert.Equal((float)1.0F, converter.ToSingle((long)1));

            Assert.Equal((ushort)1, converter.ToUInt16((double)1.0));
            Assert.Equal((ushort)1, converter.ToUInt16((int)1));
            Assert.Equal((ushort)1, converter.ToUInt16((long)1));

            Assert.Equal((uint)1, converter.ToUInt32((double)1.0));
            Assert.Equal((uint)1, converter.ToUInt32((int)1));
            Assert.Equal((uint)1, converter.ToUInt32((long)1));

            Assert.Equal((ulong)1, converter.ToUInt64((double)1.0));
            Assert.Equal((ulong)1, converter.ToUInt64((int)1));
            Assert.Equal((long)(ulong)int.MaxValue, converter.ToInt64(int.MaxValue));
            Assert.Equal(1UL, converter.ToUInt64((long)1));
            Assert.Equal((long)(ulong)long.MaxValue, converter.ToInt64(long.MaxValue));
        }