Browse files

all but 8 tests are working now #107

  • Loading branch information...
1 parent 8d90aa5 commit f8ca8f05f9753fe86bb9ff0c61ff83a7b14fc5ed @nberardi nberardi committed Jan 30, 2013
View
4 src/FluentColumnFamily.cs
@@ -205,7 +205,9 @@ public override bool TryGetColumn(object name, out object result)
{
result = GetColumnValue(name);
- return !(result is NullType);
+ // return !(result is NullType);
+ // value always is valid, a NullType is returned if it isn't found
+ return true;
}
/// <summary>
View
14 src/FluentMutationTracker.cs
@@ -18,14 +18,16 @@ protected internal FluentMutationTracker(IFluentRecord parentRecord)
public virtual void ColumnMutated(MutationType type, IFluentBaseColumn column)
{
- if (ParentRecord is FluentSuperColumn)
- {
+ if (ParentRecord is FluentSuperColumn) {
var superColumn = (FluentSuperColumn)ParentRecord;
- var superColumnFamilyMutationTracker = superColumn.Family.MutationTracker;
- // check to see if there is a mutation for this column already, so we don't create duplicate mutations
- if (!superColumnFamilyMutationTracker.GetMutations().Any(x => x.Column.ColumnName == superColumn.ColumnName))
- superColumnFamilyMutationTracker.ColumnMutated(MutationType.Changed, superColumn);
+ if (superColumn.Family != null) {
+ var superColumnFamilyMutationTracker = superColumn.Family.MutationTracker;
+
+ // check to see if there is a mutation for this column already, so we don't create duplicate mutations
+ if (!superColumnFamilyMutationTracker.GetMutations().Any(x => x.Column.ColumnName == superColumn.ColumnName))
+ superColumnFamilyMutationTracker.ColumnMutated(MutationType.Changed, superColumn);
+ }
}
_mutation.Add(new FluentMutation {
View
4 src/FluentSuperColumn.cs
@@ -232,7 +232,9 @@ public override bool TryGetColumn(object name, out object result)
{
result = GetColumnValue(name);
- return !(result is NullType);
+ // return !(result is NullType);
+ // value always is valid, a NullType is returned if it isn't found
+ return true;
}
/// <summary>
View
5 src/Linq/CqlQueryEvaluator.cs
@@ -114,7 +114,7 @@ private void AddCriteria(Expression exp)
string newCriteria = VisitWhereExpression(exp);
if (!String.IsNullOrEmpty(WhereCriteria))
- WhereCriteria = "(" + WhereCriteria + " AND " + newCriteria + ")";
+ WhereCriteria = WhereCriteria + " AND " + newCriteria;
else
WhereCriteria = newCriteria;
}
@@ -168,6 +168,9 @@ private string GetPropertyName(Expression exp)
var field = SimplifyExpression(((MethodCallExpression)exp).Arguments[0]);
+ if (field.NodeType == ExpressionType.MemberAccess)
+ return (string)Expression.Lambda(field).Compile().DynamicInvoke();
+
if (field.NodeType != ExpressionType.Constant)
throw new NotSupportedException(exp.NodeType.ToString() + " is not supported.");
View
6 test/FluentCassandra.Tests/CassandraDatabaseSetup.cs
@@ -43,10 +43,10 @@ public class User
public static readonly string Keyspace = ConfigurationManager.AppSettings["TestKeySpace"];
public static readonly Server Server = new Server(ConfigurationManager.AppSettings["TestServer"]);
-
- public CassandraDatabaseSetup(bool reset = false)
+
+ public CassandraDatabaseSetup(bool reset = false, string cqlVersion = CqlVersion.Edge)
{
- ConnectionBuilder = new ConnectionBuilder(keyspace: Keyspace, server: Server);
+ ConnectionBuilder = new ConnectionBuilder(keyspace: Keyspace, server: Server, cqlVersion: cqlVersion);
DB = new CassandraContext(ConnectionBuilder);
var exists = DB.KeyspaceExists(Keyspace);
View
7 test/FluentCassandra.Tests/CassandraDatabaseSetupFixture.cs
@@ -1,23 +1,24 @@
using System;
using System.Linq;
+using FluentCassandra.Connections;
namespace FluentCassandra
{
public class CassandraDatabaseSetupFixture
{
private static bool DatabaseHasBeenCleaned = false;
- public CassandraDatabaseSetup DatabaseSetup(bool? reset = null)
+ public CassandraDatabaseSetup DatabaseSetup(bool? reset = null, string cqlVersion = CqlVersion.Edge)
{
if (reset == null && !DatabaseHasBeenCleaned)
{
DatabaseHasBeenCleaned = true;
// refresh the entire database
- return new CassandraDatabaseSetup(reset: true);
+ return new CassandraDatabaseSetup(reset: true, cqlVersion: cqlVersion);
}
- return new CassandraDatabaseSetup(reset: reset ?? false);
+ return new CassandraDatabaseSetup(reset: reset ?? false, cqlVersion: cqlVersion);
}
}
}
View
6 test/FluentCassandra.Tests/Linq/LinqToCqlCassandraTests.cs
@@ -1,10 +1,10 @@
using System;
using System.Linq;
+using FluentCassandra.Connections;
using Xunit;
namespace FluentCassandra.Linq
-{
-
+{
public class LinqToCqlCassandraTests : IUseFixture<CassandraDatabaseSetupFixture>, IDisposable
{
private CassandraContext _db;
@@ -13,7 +13,7 @@ public class LinqToCqlCassandraTests : IUseFixture<CassandraDatabaseSetupFixture
public void SetFixture(CassandraDatabaseSetupFixture data)
{
- var setup = data.DatabaseSetup();
+ var setup = data.DatabaseSetup(cqlVersion: CqlVersion.Cql);
_db = setup.DB;
_family = setup.UserFamily;
_users = setup.Users;
View
3 test/FluentCassandra.Tests/Linq/LinqToCqlObjectsCassandraTests.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using FluentCassandra.Connections;
using Xunit;
namespace FluentCassandra.Linq
@@ -13,7 +14,7 @@ public class LinqToCqlObjectsCassandraTests : IUseFixture<CassandraDatabaseSetup
public void SetFixture(CassandraDatabaseSetupFixture data)
{
- var setup = data.DatabaseSetup();
+ var setup = data.DatabaseSetup(cqlVersion: CqlVersion.Cql);
_db = setup.DB;
_family = setup.UserFamily;
_users = setup.Users;
View
2 test/FluentCassandra.Tests/Linq/LinqToCqlTests.cs
@@ -16,7 +16,7 @@ public class LinqToCqlTests : IDisposable
public LinqToCqlTests()
{
var keyspaceName = ConfigurationManager.AppSettings["TestKeySpace"];
- var server = new Server(ConfigurationManager.AppSettings["TestServer"]);
+ var server = new Server(ConfigurationManager.AppSettings["TestServer"]);
_db = new CassandraContext(keyspace: keyspaceName, server: server);
_family = _db.GetColumnFamily<AsciiType>("Users");
View
116 test/FluentCassandra.Tests/Operations/Cql3Test.cs
@@ -5,80 +5,80 @@
namespace FluentCassandra.Operations
{
- /// <summary>
- /// Basic fluent-cassandra support for CQL3
- /// Composite keys/Count
- /// </summary>
- public class Cql3Test : IUseFixture<CassandraDatabaseSetupFixture>, IDisposable
- {
- private CassandraContext _db;
+ /// <summary>
+ /// Basic fluent-cassandra support for CQL3
+ /// Composite keys/Count
+ /// </summary>
+ public class Cql3Test : IUseFixture<CassandraDatabaseSetupFixture>, IDisposable
+ {
+ private CassandraContext _db;
public void SetFixture(CassandraDatabaseSetupFixture data)
- {
- var setup = data.DatabaseSetup();
- _db = setup.DB;
- }
+ {
+ var setup = data.DatabaseSetup(cqlVersion: CqlVersion.Cql3);
+ _db = setup.DB;
+ }
- public void Dispose()
- {
- _db.Dispose();
- }
+ public void Dispose()
+ {
+ _db.Dispose();
+ }
- [Fact]
- public void TestOverwritingOfUsersOnPrimaryKeys()
- {
- // arrange
- var insertQuery = @"INSERT INTO users (Id, Name, Email, Age) VALUES (23, '" + new String('X', 200) + "', 'test@test.com', 43)";
- var insertQuery2 = @"INSERT INTO users (Id, Name, Email, Age) VALUES (23, '" + new String('Y', 200) + "', 'test@test.com', 53)";
+ [Fact]
+ public void TestOverwritingOfUsersOnPrimaryKeys()
+ {
+ // arrange
+ var insertQuery = @"INSERT INTO users (Id, Name, Email, Age) VALUES (23, '" + new String('X', 200) + "', 'test@test.com', 43)";
+ var insertQuery2 = @"INSERT INTO users (Id, Name, Email, Age) VALUES (23, '" + new String('Y', 200) + "', 'test@test.com', 53)";
- // act
- _db.ExecuteNonQuery(insertQuery);
- _db.ExecuteNonQuery(insertQuery2);
- var actual = _db.ExecuteQuery("SELECT * FROM users");
+ // act
+ _db.ExecuteNonQuery(insertQuery);
+ _db.ExecuteNonQuery(insertQuery2);
+ var actual = _db.ExecuteQuery("SELECT * FROM users");
- // assert
- Assert.Equal(6, actual.Count());
- }
+ // assert
+ Assert.Equal(6, actual.Count());
+ }
- [Fact]
- public void TestLinq()
- {
- // arrange
- var insertQuery = @"INSERT INTO users (Id, Name, Email, Age) VALUES (23, '" + new String('X', 200) + "', 'test@test.com', 43)";
+ [Fact]
+ public void TestLinq()
+ {
+ // arrange
+ var insertQuery = @"INSERT INTO users (Id, Name, Email, Age) VALUES (23, '" + new String('X', 200) + "', 'test@test.com', 43)";
- // act
- _db.ExecuteNonQuery(insertQuery);
+ // act
+ _db.ExecuteNonQuery(insertQuery);
- var table = _db.GetColumnFamily("users");
+ var table = _db.GetColumnFamily("users");
- var q = from row in table select row;
+ var q = from row in table select row;
- var actual = q.ToList();
+ var actual = q.ToList();
- // assert
- Assert.Equal(6, actual.Count());
- }
+ // assert
+ Assert.Equal(6, actual.Count());
+ }
- /// <summary>
- /// Count() is not woriking
- /// </summary>
- [Fact]
- public void TestLinq_CountDoNotWork()
- {
- // arrange
- var insertQuery = @"INSERT INTO users (Id, Name, Email, Age) VALUES (23, '" + new String('X', 200) + "', 'test@test.com', 43)";
+ /// <summary>
+ /// Count() is not woriking
+ /// </summary>
+ [Fact]
+ public void TestLinq_CountDoNotWork()
+ {
+ // arrange
+ var insertQuery = @"INSERT INTO users (Id, Name, Email, Age) VALUES (23, '" + new String('X', 200) + "', 'test@test.com', 43)";
- // act
- _db.ExecuteNonQuery(insertQuery);
+ // act
+ _db.ExecuteNonQuery(insertQuery);
- var table = _db.GetColumnFamily("users");
+ var table = _db.GetColumnFamily("users");
- var q = from row in table select row;
+ var q = from row in table select row;
- var actualCount = q.Count();
+ var actualCount = q.Count();
- // assert
- Assert.Equal(6, actualCount);
- }
- }
+ // assert
+ Assert.Equal(6, actualCount);
+ }
+ }
}

0 comments on commit f8ca8f0

Please sign in to comment.