Пример #1
0
        public void UnsafeObjectStream_RawSeekEnd_SeeksToEndOfStream()
        {
            var stream = new UnsafeObjectStream();

            stream.AcquirePointers();
            try
            {
                unsafe
                {
                    stream.ReserveMultiple(2, 2 * sizeof(UnsafeObjectTypeOne));

                    *(UnsafeObjectTypeOne*)stream.Data = new UnsafeObjectTypeOne() { ObjectType = UnsafeObjectType.TypeOne, Value1 = 123 };
                    stream.FinalizeObject(sizeof(UnsafeObjectTypeOne));

                    *(UnsafeObjectTypeOne*)stream.Data = new UnsafeObjectTypeOne() { ObjectType = UnsafeObjectType.TypeOne, Value1 = 234 };
                    stream.FinalizeObject(sizeof(UnsafeObjectTypeOne));

                    stream.RawSeekEnd();

                    TheResultingValue(stream.PositionInObjects).ShouldBe(stream.LengthInObjects);
                    TheResultingValue(stream.PositionInBytes).ShouldBe(stream.LengthInBytes);
                }
            }
            finally
            {
                stream.ReleasePointers();
            }
        }