Browse files

merged in change from bjuris

  • Loading branch information...
2 parents 49e17ca + d74583a commit 3d550794cdac1cd020f09a52be22df4d4fa8ae43 @nberardi nberardi committed Apr 3, 2012
View
4 src/FluentColumn.cs
@@ -125,8 +125,8 @@ internal set
if (value.HasValue)
ColumnSecondsUntilDeleted = Convert.ToInt32(value.Value.TotalSeconds);
-
- ColumnSecondsUntilDeleted = null;
+ else
+ ColumnSecondsUntilDeleted = null;
}
}
View
7 src/Operations/Helper.cs
@@ -308,11 +308,16 @@ public static Mutation CreateInsertedOrChangedMutation(FluentMutation mutation)
public static Column CreateColumn(FluentColumn column)
{
- return new Column {
+ var col = new Column {
Name = column.ColumnName.TryToBigEndian(),
Value = column.ColumnValue.TryToBigEndian(),
Timestamp = column.ColumnTimestamp.ToTimestamp()
};
+ if (column.ColumnSecondsUntilDeleted.HasValue)
+ {
+ col.Ttl = column.ColumnSecondsUntilDeleted.Value;
+ }
+ return col;
}
public static ColumnOrSuperColumn CreateColumnOrSuperColumn(IFluentBaseColumn column)
View
3 test/FluentCassandra.Tests/FluentCassandra.Tests.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -74,6 +74,7 @@
<Compile Include="TypesToDatabase\LongTypeTest.cs" />
<Compile Include="TypesToDatabase\UTF8TypeTest.cs" />
<Compile Include="Types\CompositeTypeTest.cs" />
+ <Compile Include="Types\CassandraTypeTest.cs" />
<Compile Include="Types\DynamicCompositeTypeTest.cs" />
<Compile Include="Types\IntegerTypeTest.cs" />
<Compile Include="CassandraDatabaseSetup.cs" />
View
70 test/FluentCassandra.Tests/Types/CassandraTypeTest.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Text;
+using System.Linq;
+using NUnit.Framework;
+
+namespace FluentCassandra.Types
+{
+ [TestFixture]
+ public class CassandraTypeTest
+ {
+ [Test]
+ public void Parse_CompositeType()
+ {
+ // arrange
+ Type expected = typeof(CompositeType<TimeUUIDType, UTF8Type>);
+ string cassandraString = "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.TimeUUIDType,org.apache.cassandra.db.marshal.UTF8Type)";
+
+ // act
+ Type actual = new CassandraType(cassandraString).FluentType;
+
+ // assert
+ Assert.AreEqual(expected, actual);
+ }
+
+ [Test]
+ public void Parse_Type()
+ {
+ // arrange
+ Type expected = typeof(UTF8Type);
+ string cassandraString = "org.apache.cassandra.db.marshal.UTF8Type";
+
+ // act
+ Type actual = new CassandraType(cassandraString).FluentType;
+
+ // assert
+ Assert.AreEqual(expected, actual);
+ }
+
+ [Test, ExpectedException(typeof(CassandraException))]
+ public void Parse_CompositeType_UnknownInnerType()
+ {
+ // arranage
+ string cassandraString = "org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.TimeUUIDType,org.apache.cassandra.db.marshal.UnkownTypeForTesting)";
+
+ // act
+ Type actual = new CassandraType(cassandraString).FluentType;
+ }
+
+ [Test,ExpectedException(typeof(CassandraException))]
+ public void Parse_UnknownType()
+ {
+ // arranage
+ string cassandraString = "org.apache.cassandra.db.marshal.UnkownTypeForTesting";
+
+ // act
+ Type actual = new CassandraType(cassandraString).FluentType;
+ }
+
+ [Test, ExpectedException(typeof(CassandraException))]
+ public void Parse_UnknownTypeWithParams()
+ {
+ // arranage
+ Type expected = typeof(UTF8Type);
+ string cassandraString = "org.apache.cassandra.db.marshal.UnkownTypeForTesting(org.apache.cassandra.db.marshal.TimeUUIDType,org.apache.cassandra.db.marshal.UTF8Type)";
+
+ // act
+ Type actual = new CassandraType(cassandraString).FluentType;
+ }
+ }
+}

0 comments on commit 3d55079

Please sign in to comment.