Permalink
Browse files

all tests working for 0.7

  • Loading branch information...
1 parent 8d89c81 commit ce017c8f9d5967bb7f7c328a5527f3ec9537bb57 @nberardi nberardi committed Sep 5, 2010
Showing with 248 additions and 256 deletions.
  1. +4 −4 FluentCassandra.Sandbox/Program.cs
  2. +4 −11 FluentCassandra.Test/CassandraQueryTest.cs
  3. +3 −3 FluentCassandra.Test/Connection/ConnectionProviderTest.cs
  4. +1 −1 FluentCassandra.Test/Connection/NormalConnectionProviderTest.cs
  5. +5 −13 FluentCassandra.Test/Operations/ColumnCountTest.cs
  6. +4 −11 FluentCassandra.Test/Operations/GetColumnTest.cs
  7. +4 −19 FluentCassandra.Test/Operations/GetRangeSliceTest.cs
  8. +4 −11 FluentCassandra.Test/Operations/GetSliceTest.cs
  9. +8 −5 FluentCassandra.Test/Operations/InsertColumnTest.cs
  10. +4 −19 FluentCassandra.Test/Operations/MultiGetSliceTest.cs
  11. +5 −15 FluentCassandra.Test/Operations/RemoveColumnTest.cs
  12. +4 −24 FluentCassandra.Test/Types/NullTypeTest.cs
  13. +47 −31 FluentCassandra.Test/_CassandraSetup.cs
  14. +10 −1 FluentCassandra/BaseCassandraColumnFamily.cs
  15. +6 −5 FluentCassandra/CassandraColumnFamilyOperations.cs
  16. +53 −7 FluentCassandra/CassandraKeyspace.cs
  17. +23 −48 FluentCassandra/CassandraSession.cs
  18. +8 −7 FluentCassandra/CassandraSuperColumnFamilyOperations.cs
  19. +10 −12 FluentCassandra/Connection/Connection.cs
  20. +0 −4 FluentCassandra/Connection/ConnectionBuilder.cs
  21. +1 −0 FluentCassandra/FluentCassandra.csproj
  22. +10 −0 FluentCassandra/FluentColumn.cs
  23. +1 −0 FluentCassandra/IFluentColumn.cs
  24. +6 −1 FluentCassandra/Operations/ColumnFamilyOperation.cs
  25. +7 −3 FluentCassandra/Operations/InsertColumn.cs
  26. +2 −1 FluentCassandra/Operations/ObjectHelper.cs
  27. +14 −0 FluentCassandra/Operations/Truncate.cs
@@ -21,10 +21,10 @@ private static void Main()
TProtocol framedProtocol = new TBinaryProtocol(framedTransport);
TProtocol socketProtocol = new TBinaryProtocol(socketTransport);
- //var client = new Cassandra.Client(framedProtocol, framedProtocol); // all framed
+ var client = new Cassandra.Client(framedProtocol, framedProtocol); // all framed
//var client = new Cassandra.Client(socketProtocol, socketProtocol); // all socket
//var client = new Cassandra.Client(framedProtocol, socketProtocol); // in: framed out: socket
- var client = new Cassandra.Client(socketProtocol, framedProtocol); // in: socket out: framed
+ //var client = new Cassandra.Client(socketProtocol, framedProtocol); // in: socket out: framed
framedTransport.Open();
socketTransport.Open();
@@ -33,8 +33,8 @@ private static void Main()
client.set_keyspace("Keyspace1");
Console.WriteLine("Count Key");
- var key = System.Text.Encoding.ASCII.GetBytes("MyKey");
- var columns = new List<byte[]>(new[] { System.Text.Encoding.ASCII.GetBytes("MyColumn") });
+ var key = Encoding.ASCII.GetBytes("MyKey");
+ var columns = new List<byte[]>(new[] { Encoding.ASCII.GetBytes("MyColumn") });
var column_parent = new ColumnParent {
Column_family = "Standard1"
};
@@ -20,17 +20,10 @@ public class CassandraQueryTest
[TestInitialize]
public void TestInit()
{
- _db = new CassandraContext("Testing", "localhost");
- _family = _db.GetColumnFamily<AsciiType>("Standard");
- _superFamily = _db.GetColumnFamily<AsciiType, AsciiType>("Super");
-
- _family.InsertColumn(_testKey, "Test1", Math.PI);
- _family.InsertColumn(_testKey, "Test2", Math.PI);
- _family.InsertColumn(_testKey, "Test3", Math.PI);
-
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test1", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test2", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test3", Math.PI);
+ var setup = new _CassandraSetup();
+ _db = setup.DB;
+ _family = setup.Family;
+ _superFamily = setup.SuperFamily;
}
[TestCleanup]
@@ -4,7 +4,7 @@
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-namespace FluentCassandra.Connection.Test
+namespace FluentCassandra.Test.Connection
{
[TestClass]
public class ConnectionProviderTest
@@ -14,7 +14,7 @@ public void NormalConnectionProvider()
{
// arrange
var expected = typeof(NormalConnectionProvider);
- var connectionString = "";
+ var connectionString = "Keyspace=Testing";
// act
var result = new ConnectionBuilder(connectionString);
@@ -29,7 +29,7 @@ public void PooledConnectionProvider()
{
// arrange
var expected = typeof(PooledConnectionProvider);
- var connectionString = "Pooled=True";
+ var connectionString = "Keyspace=Testing;Pooled=True";
// act
var result = new ConnectionBuilder(connectionString);
@@ -12,7 +12,7 @@ public class NormalConnectionProviderTest
/// <summary>
/// Needed to switch to testing ports since the network timeout was making the tests unbearably long.
/// </summary>
- private static string FailoverConnectionString = "Timeout=1;Server=127.0.0.1:1234,127.0.0.1:4567,127.0.0.1";
+ private static string FailoverConnectionString = "Keyspace=Testing;Timeout=1;Server=127.0.0.1:1234,127.0.0.1:4567,127.0.0.1";
[TestMethod]
public void Fails_Over()
@@ -20,9 +20,10 @@ public class ColumnCountTest
[TestInitialize]
public void TestInit()
{
- _db = new CassandraContext("Testing", "localhost");
- _family = _db.GetColumnFamily<AsciiType>("Standard");
- _superFamily = _db.GetColumnFamily<AsciiType, AsciiType>("Super");
+ var setup = new _CassandraSetup();
+ _db = setup.DB;
+ _family = setup.Family;
+ _superFamily = setup.SuperFamily;
}
[TestCleanup]
@@ -36,9 +37,6 @@ public void ColumnFamily_Key()
{
// arrange
int expected = 3;
- _family.InsertColumn(_testKey, "Test1", Math.PI);
- _family.InsertColumn(_testKey, "Test2", Math.PI);
- _family.InsertColumn(_testKey, "Test3", Math.PI);
// act
int actual = _family.ColumnCount(_testKey, null, null);
@@ -52,9 +50,6 @@ public void SuperColumnFamily_Key()
{
// arrange
int expected = 1;
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test1", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test2", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test3", Math.PI);
// act
int actual = _superFamily.ColumnCount(_testKey, null, null);
@@ -68,12 +63,9 @@ public void SuperColumnFamily_Key_And_SuperColumnName()
{
// arrange
int expected = 3;
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test1", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test2", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test3", Math.PI);
// act
- int actual = _superFamily.ColumnCount(_testKey, _testSuperName, null, null);
+ int actual = _superFamily.SuperColumnCount(_testKey, _testSuperName, null, null);
// assert
Assert.AreEqual(expected, actual);
@@ -20,17 +20,10 @@ public class GetColumnTest
[TestInitialize]
public void TestInit()
{
- _db = new CassandraContext("Testing", "localhost");
- _family = _db.GetColumnFamily<AsciiType>("Standard");
- _superFamily = _db.GetColumnFamily<AsciiType, AsciiType>("Super");
-
- _family.InsertColumn(_testKey, "Test1", Math.PI);
- _family.InsertColumn(_testKey, "Test2", Math.PI);
- _family.InsertColumn(_testKey, "Test3", Math.PI);
-
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test1", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test2", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test3", Math.PI);
+ var setup = new _CassandraSetup();
+ _db = setup.DB;
+ _family = setup.Family;
+ _superFamily = setup.SuperFamily;
}
[TestCleanup]
@@ -21,25 +21,10 @@ public class GetRangeSliceTest
[TestInitialize]
public void TestInit()
{
- _db = new CassandraContext("Testing", "localhost");
- _family = _db.GetColumnFamily<AsciiType>("Standard");
- _superFamily = _db.GetColumnFamily<AsciiType, AsciiType>("Super");
-
- _family.InsertColumn(_testKey, "Test1", Math.PI);
- _family.InsertColumn(_testKey, "Test2", Math.PI);
- _family.InsertColumn(_testKey, "Test3", Math.PI);
-
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test1", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test2", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test3", Math.PI);
-
- _family.InsertColumn(_testKey2, "Test1", Math.PI);
- _family.InsertColumn(_testKey2, "Test2", Math.PI);
- _family.InsertColumn(_testKey2, "Test3", Math.PI);
-
- _superFamily.InsertColumn(_testKey2, _testSuperName, "Test1", Math.PI);
- _superFamily.InsertColumn(_testKey2, _testSuperName, "Test2", Math.PI);
- _superFamily.InsertColumn(_testKey2, _testSuperName, "Test3", Math.PI);
+ var setup = new _CassandraSetup();
+ _db = setup.DB;
+ _family = setup.Family;
+ _superFamily = setup.SuperFamily;
}
[TestCleanup]
@@ -20,17 +20,10 @@ public class GetSliceTest
[TestInitialize]
public void TestInit()
{
- _db = new CassandraContext("Testing", "localhost");
- _family = _db.GetColumnFamily<AsciiType>("Standard");
- _superFamily = _db.GetColumnFamily<AsciiType, AsciiType>("Super");
-
- _family.InsertColumn(_testKey, "Test1", Math.PI);
- _family.InsertColumn(_testKey, "Test2", Math.PI);
- _family.InsertColumn(_testKey, "Test3", Math.PI);
-
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test1", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test2", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test3", Math.PI);
+ var setup = new _CassandraSetup();
+ _db = setup.DB;
+ _family = setup.Family;
+ _superFamily = setup.SuperFamily;
}
[TestCleanup]
@@ -20,9 +20,10 @@ public class InsertColumnTest
[TestInitialize]
public void TestInit()
{
- _db = new CassandraContext("Testing", "localhost");
- _family = _db.GetColumnFamily<AsciiType>("Standard");
- _superFamily = _db.GetColumnFamily<AsciiType, AsciiType>("Super");
+ var setup = new _CassandraSetup();
+ _db = setup.DB;
+ _family = setup.Family;
+ _superFamily = setup.SuperFamily;
}
[TestCleanup]
@@ -37,9 +38,10 @@ public void ColumnFamily()
// arrange
double value = Math.PI;
DateTimeOffset timestamp = DateTimeOffset.UtcNow;
+ int timeToLive = 1;
// act
- _family.InsertColumn(_testKey, _testName, value, timestamp);
+ _family.InsertColumn(_testKey, _testName, value, timestamp, timeToLive);
// assert
}
@@ -50,9 +52,10 @@ public void SuperColumnFamily()
// arrange
double value = Math.PI;
DateTimeOffset timestamp = DateTimeOffset.UtcNow;
+ int timeToLive = 1;
// act
- _superFamily.InsertColumn(_testKey, _testSuperName, _testName, value, timestamp);
+ _superFamily.InsertColumn(_testKey, _testSuperName, _testName, value, timestamp, timeToLive);
// assert
}
@@ -21,25 +21,10 @@ public class MultiGetSliceTest
[TestInitialize]
public void TestInit()
{
- _db = new CassandraContext("Testing", "localhost");
- _family = _db.GetColumnFamily<AsciiType>("Standard");
- _superFamily = _db.GetColumnFamily<AsciiType, AsciiType>("Super");
-
- _family.InsertColumn(_testKey, "Test1", Math.PI);
- _family.InsertColumn(_testKey, "Test2", Math.PI);
- _family.InsertColumn(_testKey, "Test3", Math.PI);
-
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test1", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test2", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test3", Math.PI);
-
- _family.InsertColumn(_testKey2, "Test1", Math.PI);
- _family.InsertColumn(_testKey2, "Test2", Math.PI);
- _family.InsertColumn(_testKey2, "Test3", Math.PI);
-
- _superFamily.InsertColumn(_testKey2, _testSuperName, "Test1", Math.PI);
- _superFamily.InsertColumn(_testKey2, _testSuperName, "Test2", Math.PI);
- _superFamily.InsertColumn(_testKey2, _testSuperName, "Test3", Math.PI);
+ var setup = new _CassandraSetup();
+ _db = setup.DB;
+ _family = setup.Family;
+ _superFamily = setup.SuperFamily;
}
[TestCleanup]
@@ -1,7 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FluentCassandra.Types;
@@ -20,17 +17,10 @@ public class RemoveColumnTest
[TestInitialize]
public void TestInit()
{
- _db = new CassandraContext("Testing", "localhost");
- _family = _db.GetColumnFamily<AsciiType>("Standard");
- _superFamily = _db.GetColumnFamily<AsciiType, AsciiType>("Super");
-
- _family.InsertColumn(_testKey, "Test1", Math.PI);
- _family.InsertColumn(_testKey, "Test2", Math.PI);
- _family.InsertColumn(_testKey, "Test3", Math.PI);
-
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test1", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test2", Math.PI);
- _superFamily.InsertColumn(_testKey, _testSuperName, "Test3", Math.PI);
+ var setup = new _CassandraSetup();
+ _db = setup.DB;
+ _family = setup.Family;
+ _superFamily = setup.SuperFamily;
}
[TestCleanup]
@@ -77,7 +67,7 @@ public void Super_RemoveColumn()
_superFamily.RemoveColumn(_testKey, _testSuperName, _testName);
// assert
- int actualCount = _superFamily.ColumnCount(_testKey, _testSuperName, null, null);
+ int actualCount = _superFamily.SuperColumnCount(_testKey, _testSuperName, null, null);
Assert.AreEqual(expectedCount, actualCount);
}
@@ -10,36 +10,15 @@ namespace FluentCassandra.Test.Types
[TestClass]
public class NullTypeTest
{
- private CassandraContext _db;
- private CassandraColumnFamily<AsciiType> _family;
- private CassandraSuperColumnFamily<AsciiType, AsciiType> _superFamily;
- private const string _testKey = "Test1";
- private const string _testName = "Test1";
- private const string _testSuperName = "SubTest1";
-
- [TestInitialize]
- public void TestInit()
- {
- var setup = new _CassandraSetup();
- _db = setup.DB;
- _family = setup.Family;
- _superFamily = setup.SuperFamily;
- }
-
- [TestCleanup]
- public void TestCleanup()
- {
- _db.Dispose();
- }
-
[TestMethod]
public void Implicity_Cast_To_Int64()
{
// arranage
long? expected = null;
+ dynamic family = new FluentColumnFamily<AsciiType>("Test1", "Test1");
// act
- long? actual = _family.Get(_testKey).Fetch(_testName).FirstOrDefault().AsDynamic().ShouldNotBeFound;
+ long? actual = family.ShouldNotBeFound;
// assert
Assert.AreEqual(expected, actual);
@@ -51,9 +30,10 @@ public void Implicity_Cast_To_FluentSuperColumn()
// arranage
var expectedName = "ShouldNotBeFound";
var expectedColumnCount = 0;
+ dynamic family = new FluentSuperColumnFamily<AsciiType, AsciiType>("Test1", "SubTest1");
// act
- FluentSuperColumn<AsciiType, AsciiType> actual = _superFamily.Get(_testKey).FirstOrDefault().AsDynamic().ShouldNotBeFound;
+ FluentSuperColumn<AsciiType, AsciiType> actual = family.ShouldNotBeFound;
// assert
Assert.AreEqual(expectedName, (string)actual.ColumnName);
Oops, something went wrong.

0 comments on commit ce017c8

Please sign in to comment.