public void TestActualizeWithNullProperties()
        {
            var keyspaceName = TestSchemaUtils.GetRandomKeyspaceName();
            var scheme       = new KeyspaceScheme
            {
                Name          = keyspaceName,
                Configuration = new KeyspaceConfiguration
                {
                    ColumnFamilies = new[]
                    {
                        new ColumnFamily
                        {
                            Name        = "CF1",
                            Compression = ColumnFamilyCompression.Deflate(new CompressionOptions {
                                ChunkLengthInKb = 1024
                            }),
                            Caching = ColumnFamilyCaching.KeysOnly
                        }
                    }
                }
            };

            ActualizeKeyspaces(scheme);

            var actualScheme = cluster.RetrieveKeyspaceConnection(keyspaceName).DescribeKeyspace();

            Assert.That(actualScheme.ColumnFamilies["CF1"].Compression.Algorithm, Is.EqualTo(CompressionAlgorithms.Deflate));

            scheme.Configuration.ColumnFamilies[0].Compression = null;
            scheme.Configuration.ColumnFamilies[0].Caching     = ColumnFamilyCaching.All;
            ActualizeKeyspaces(scheme);

            actualScheme = cluster.RetrieveKeyspaceConnection(keyspaceName).DescribeKeyspace();
            Assert.That(actualScheme.ColumnFamilies["CF1"].Compression.Algorithm, Is.EqualTo(CompressionAlgorithms.LZ4));
        }
        public void TestCreateColumnFamilyWithCompression()
        {
            InternalTestCreateColumnFamilyCompression(ColumnFamilyCompression.LZ4(new CompressionOptions {
                ChunkLengthInKb = 128
            }));
            InternalTestCreateColumnFamilyCompression(ColumnFamilyCompression.LZ4(new CompressionOptions {
                ChunkLengthInKb = 1024
            }));

            InternalTestCreateColumnFamilyCompression(ColumnFamilyCompression.Snappy(new CompressionOptions {
                ChunkLengthInKb = 32
            }));
            InternalTestCreateColumnFamilyCompression(ColumnFamilyCompression.Snappy(new CompressionOptions {
                ChunkLengthInKb = 1024
            }));

            InternalTestCreateColumnFamilyCompression(ColumnFamilyCompression.Deflate(new CompressionOptions {
                ChunkLengthInKb = 2
            }));
            InternalTestCreateColumnFamilyCompression(ColumnFamilyCompression.Deflate(new CompressionOptions {
                ChunkLengthInKb = 1024
            }));

            InternalTestCreateColumnFamilyCompression(ColumnFamilyCompression.None());
        }
        public void TestChangeCompressionProperty()
        {
            var scheme = new KeyspaceScheme
            {
                Name          = TestSchemaUtils.GetRandomKeyspaceName(),
                Configuration = new KeyspaceConfiguration
                {
                    ColumnFamilies = new[]
                    {
                        new ColumnFamily
                        {
                            Name = "CF1"
                        }
                    }
                }
            };

            ActualizeKeyspaces(scheme);
            Assert.That(cluster.UpdateColumnFamilyInvokeCount, Is.EqualTo(0));
            scheme.Configuration.ColumnFamilies[0].Compression = ColumnFamilyCompression.Deflate(new CompressionOptions {
                ChunkLengthInKb = 1024
            });
            ActualizeKeyspaces(scheme);
            Assert.That(cluster.UpdateColumnFamilyInvokeCount, Is.EqualTo(1));
        }
 public void TestTryCreateColumnFamilyWithWrongChunkLength()
 {
     Assert.Throws <CassandraClientInvalidRequestException>(
         () => keyspaceConnection.AddColumnFamily(new ColumnFamily
     {
         Name        = TestSchemaUtils.GetRandomColumnFamilyName(),
         Compression = ColumnFamilyCompression.Deflate(new CompressionOptions {
             ChunkLengthInKb = 3
         })
     }));
 }
 public void TestCompareColumnFamiliesByCompression()
 {
     Assert.That(
         !comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.Deflate(new CompressionOptions {
             ChunkLengthInKb = 2
         })
     },
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.Deflate(new CompressionOptions {
             ChunkLengthInKb = 2
         })
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.Deflate(new CompressionOptions {
             ChunkLengthInKb = 3
         })
     },
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.Deflate(new CompressionOptions {
             ChunkLengthInKb = 2
         })
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.Snappy(new CompressionOptions {
             ChunkLengthInKb = 2
         })
     },
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.Deflate(new CompressionOptions {
             ChunkLengthInKb = 2
         })
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.Snappy(new CompressionOptions {
             ChunkLengthInKb = 2
         })
     },
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.LZ4(new CompressionOptions {
             ChunkLengthInKb = 2
         })
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.None()
     },
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.Deflate(new CompressionOptions {
             ChunkLengthInKb = 2
         })
     })
         );
     Assert.That(
         !comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", Compression = null
     },
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.Deflate(new CompressionOptions {
             ChunkLengthInKb = 2
         })
     })
         );
     Assert.That(
         comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.Deflate(new CompressionOptions {
             ChunkLengthInKb = 2
         })
     },
             new ColumnFamily {
         Name = "name", Compression = null
     })
         );
     Assert.That(
         !comparer.NeedUpdateColumnFamily(
             new ColumnFamily {
         Name = "name", Compression = null
     },
             new ColumnFamily {
         Name = "name", Compression = ColumnFamilyCompression.Snappy(null)
     })
         );
 }