BTDBTest.InMemoryInMemoryKeyValueDBTest.SetKeyPrefixInOneTransaction C# (CSharp) Méthode

SetKeyPrefixInOneTransaction() private méthode

private SetKeyPrefixInOneTransaction ( ) : void
Résultat void
        public void SetKeyPrefixInOneTransaction()
        {
            using (IKeyValueDB db = new InMemoryKeyValueDB())
            {
                var key = new byte[5];
                var value = new byte[100];
                var rnd = new Random();
                using (var tr = db.StartTransaction())
                {
                    for (byte i = 0; i < 100; i++)
                    {
                        key[0] = i;
                        for (byte j = 0; j < 100; j++)
                        {
                            key[4] = j;
                            rnd.NextBytes(value);
                            tr.CreateOrUpdateKeyValue(key, value);
                        }
                    }
                    tr.Commit();
                }
                using (var tr = db.StartTransaction())
                {
                    for (byte i = 0; i < 100; i++)
                    {
                        key[0] = i;
                        tr.SetKeyPrefix(ByteBuffer.NewSync(key, 0, 4));
                        Assert.Equal(100, tr.GetKeyValueCount());
                    }
                }
            }
        }