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

                var actualIndex = new TableSchema.SchemaIndexDef
                {
                    StartIndex = 1,
                    Count      = 1,
                };
                Slice.From(tx.Allocator, "Bad Test Name", ByteStringType.Immutable, out actualIndex.Name);

                Assert.Throws <ArgumentNullException>(delegate { expectedIndex.Validate(null); });
                Assert.Throws <ArgumentException>(delegate { expectedIndex.Validate(actualIndex); });
            }
        }
Esempio n. 2
0
        public void CanSerializeNormalIndex()
        {
            using (var tx = Env.WriteTransaction())
            {
                var expectedIndex = new TableSchema.SchemaIndexDef
                {
                    StartIndex = 2,
                    Count      = 1,
                };
                Slice.From(tx.Allocator, "Test Name", ByteStringType.Immutable, out expectedIndex.Name);

                byte[] serialized = expectedIndex.Serialize();

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

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