コード例 #1
0
ファイル: Validate.cs プロジェクト: rstonkus/ravendb
        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); });
            }
        }
コード例 #2
0
ファイル: Serialization.cs プロジェクト: yitaom2/ravendb
        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);
                }
            }
        }