Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added unit tests designed to cover InsertCounterColumn - tests normal…

… counter column families and super counter column families
  • Loading branch information...
commit fcdd575534e0d4966d42c6608f0641bd78454f7d 1 parent 012870e
@Aaronontheweb Aaronontheweb authored
View
2  test/FluentCassandra.Integration.Tests/CassandraDatabaseSetup.cs
@@ -92,7 +92,7 @@ public void ResetDatabase()
ColumnNameType = CassandraType.AsciiType,
DefaultColumnValueType = CassandraType.CounterColumnType
});
- keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema()
+ keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema(type:ColumnType.Super)
{
FamilyName = "SuperCounters",
SuperColumnNameType = CassandraType.AsciiType,
View
1  test/FluentCassandra.Integration.Tests/FluentCassandra.Integration.Tests.csproj
@@ -56,6 +56,7 @@
<Compile Include="Operations\GetRangeSliceTest.cs" />
<Compile Include="Operations\GetSliceTest.cs" />
<Compile Include="Operations\InsertColumnTest.cs" />
+ <Compile Include="Operations\InsertCounterColumnTest.cs" />
<Compile Include="Operations\MultiGetSliceTest.cs" />
<Compile Include="Operations\RemoveColumnTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
View
71 test/FluentCassandra.Integration.Tests/Operations/InsertCounterColumnTest.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Linq;
+using FluentCassandra.Types;
+using Xunit;
+
+
+namespace FluentCassandra.Integration.Tests.Operations
+{
+ public class InsertCounterColumnTest : IUseFixture<CassandraDatabaseSetupFixture>, IDisposable
+ {
+ private CassandraContext _db;
+ private CassandraColumnFamily _counterFamily;
+ private CassandraSuperColumnFamily _superCounterFamily;
+
+ public InsertCounterColumnTest()
+ {
+ //Create a new row each time we run the test, so the expected counter values are always equal to 1
+ _testKey = Guid.NewGuid().ToString();
+ }
+
+ public void SetFixture(CassandraDatabaseSetupFixture data)
+ {
+ var setup = data.DatabaseSetup();
+ _db = setup.DB;
+ _counterFamily = setup.CounterFamily;
+ _superCounterFamily = setup.SuperCounterFamily;
+ }
+
+ public void Dispose()
+ {
+ _db.Dispose();
+ }
+
+ private readonly string _testKey;
+ private const string _testName = "Test1";
+ private const string _testSuperName = "SubTest1";
+
+ [Fact]
+ public void CounterColumnFamily()
+ {
+ //arrange
+ long value = 1L;
+
+ //act
+ _counterFamily.InsertCounterColumn(_testKey, _testName, value);
+ var column = _counterFamily.Get(_testKey).Execute();
+ var actual = column.FirstOrDefault().Columns.FirstOrDefault();
+
+ // assert
+ Assert.Equal(_testName, (string)actual.ColumnName);
+ Assert.Equal(value, (double)actual.ColumnValue);
+ }
+
+ [Fact]
+ public void SuperCounterColumnFamily()
+ {
+ //arrange
+ long value = 1L;
+
+ //act
+ _superCounterFamily.InsertCounterColumn(_testKey, _testSuperName, _testName, value);
+ var column = _superCounterFamily.Get(_testKey).Execute();
+ var actual = column.FirstOrDefault().Columns.FirstOrDefault();
+
+ // assert
+ Assert.Equal(_testSuperName, (string)actual.ColumnName);
+ Assert.Equal(_testName, (string)actual.Columns[0].ColumnName);
+ Assert.Equal(value, (double)actual.Columns[0].ColumnValue);
+ }
+ }
+}

0 comments on commit fcdd575

Please sign in to comment.
Something went wrong with that request. Please try again.