Пример #1
0
        public void UnsafeObjectStream_RawSeekBeginning_SeeksToBeginningOfStream()
        {
            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.RawSeekBeginning();

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