private static void AssertArraySegment(MessagePackObject expected, ArraySegment <byte> actual)
        {
            var result = Unpacking.UnpackObject(actual.AsEnumerable().ToArray());

            Assert.That(result.ReadCount, Is.EqualTo(actual.Count));
            Assert.That(expected.Equals(result.Value));
        }
示例#2
0
        /// <summary>
        /// Cuts out <paramref name="segment"/> from <paramref name="tuple"/> <see cref="Tuple"/>.
        /// </summary>
        /// <param name="tuple">The <see cref="Tuple"/> to get segment from.</param>
        /// <param name="segment">The <see cref="Segment{T}"/> to cut off.</param>
        /// <returns></returns>
        public static Tuple GetSegment(this Tuple tuple, Segment <int> segment)
        {
            var map = new int[segment.Length];

            for (int i = 0; i < segment.Length; i++)
            {
                map[i] = segment.Offset + i;
            }

            var types      = new ArraySegment <Type>(tuple.Descriptor.FieldTypes, segment.Offset, segment.Length);
            var descriptor = TupleDescriptor.Create(types.AsEnumerable());
            var transform  = new MapTransform(false, descriptor, map);

            return(transform.Apply(TupleTransformType.TransformedTuple, tuple));
        }
		private static void AssertArraySegment( MessagePackObject expected, ArraySegment<byte> actual )
		{
			var result = Unpacking.UnpackObject( actual.AsEnumerable().ToArray() );
			Assert.That( result.ReadCount, Is.EqualTo( actual.Count ) );
			Assert.That( expected.Equals( result.Value ) );
		}