Ejemplo n.º 1
0
        public void ErrorsOnInvalidFixedSizeDef()
        {
            using (var tx = Env.WriteTransaction())
            {
                var expectedIndex = new TableSchema.FixedSizeSchemaIndexDef
                {
                    StartIndex = 2,
                };
                Slice.From(tx.Allocator, "Test Name", ByteStringType.Immutable, out expectedIndex.Name);

                var actualIndex = new TableSchema.FixedSizeSchemaIndexDef
                {
                    StartIndex = 5,
                };
                Slice.From(tx.Allocator, "Test Name", ByteStringType.Immutable, out actualIndex.Name);

                Assert.Throws <ArgumentNullException>(delegate { expectedIndex.Validate(null); });
                Assert.Throws <ArgumentException>(delegate { expectedIndex.Validate(actualIndex); });
            }
        }
Ejemplo n.º 2
0
        public void CanSerializeFixedIndex()
        {
            using (var tx = Env.WriteTransaction())
            {
                var expectedIndex = new TableSchema.FixedSizeSchemaIndexDef
                {
                    StartIndex = 2,
                    IsGlobal   = true,
                };
                Slice.From(tx.Allocator, "Test Name 2", ByteStringType.Immutable, out expectedIndex.Name);

                byte[] serialized = expectedIndex.Serialize();

                fixed(byte *serializedPtr = serialized)
                {
                    var actualIndex = TableSchema.FixedSizeSchemaIndexDef.ReadFrom(tx.Allocator, serializedPtr, serialized.Length);

                    Assert.Equal(serialized, actualIndex.Serialize());
                    FixedSchemaIndexDefEqual(expectedIndex, actualIndex);
                    expectedIndex.Validate(actualIndex);
                }
            }
        }