Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added test to verify fix of issue #61.

  • Loading branch information...
commit 8caa7bfcb8b96d701313fbd63d7185a26e3accf5 1 parent 242daad
Scott Smerchek authored September 05, 2012
71  test/FluentCassandra.Tests/Bugs/Issue61SuperColumnRangeSliceKeyBackwards.cs
... ...
@@ -0,0 +1,71 @@
  1
+using System;
  2
+using System.Collections.Generic;
  3
+using System.Linq;
  4
+using FluentCassandra.Types;
  5
+using Xunit;
  6
+
  7
+namespace FluentCassandra.Bugs
  8
+{
  9
+	public class Issue61SuperColumnRangeSliceKeyBackwards : IUseFixture<CassandraDatabaseSetupFixture>, IDisposable
  10
+	{
  11
+		private CassandraContext _db;
  12
+
  13
+		public void SetFixture(CassandraDatabaseSetupFixture data)
  14
+		{
  15
+			var setup = data.DatabaseSetup();
  16
+			_db = setup.DB;
  17
+		}
  18
+
  19
+		public void Dispose()
  20
+		{
  21
+			_db.Dispose();
  22
+		}
  23
+
  24
+		[Fact]
  25
+		public void Test_GetRangeSlice()
  26
+		{
  27
+			// arrange
  28
+			var keyspace = _db.Keyspace;
  29
+
  30
+			// create column family using API
  31
+			_db.TryDropColumnFamily("supercolumns");
  32
+
  33
+         keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema
  34
+         {
  35
+            FamilyName = "supercolumns",
  36
+            FamilyType = ColumnType.Super,
  37
+            KeyValueType = CassandraType.UTF8Type,
  38
+            SuperColumnNameType = CassandraType.TimeUUIDType,
  39
+            ColumnNameType = CassandraType.UTF8Type,
  40
+            DefaultColumnValueType = CassandraType.UTF8Type
  41
+         });
  42
+
  43
+		   InsertData("testKey");
  44
+
  45
+			// act
  46
+		   var actual = _db.GetSuperColumnFamily("supercolumns").Get().TakeKeys(5);
  47
+
  48
+			// assert
  49
+			Assert.NotNull(actual);
  50
+			Assert.Equal(1, actual.Count());
  51
+		   Assert.Equal("testKey", actual.First().Key.ToString());
  52
+		}
  53
+
  54
+		public void InsertData(string key)
  55
+		{
  56
+			var productFamily = _db.GetSuperColumnFamily("supercolumns");
  57
+
  58
+         var post = productFamily.CreateRecord(key);
  59
+         _db.Attach(post);
  60
+          
  61
+         for (int i = 0; i < 4; i++)
  62
+		   {
  63
+            dynamic d = post.CreateSuperColumn(GuidGenerator.GenerateTimeBasedGuid(DateTimeOffset.Now.Subtract(TimeSpan.FromSeconds(i))));
  64
+		      d.columnone = Guid.NewGuid().ToString();
  65
+		      d.columntwo = Guid.NewGuid().ToString();
  66
+		   }
  67
+
  68
+			_db.SaveChanges();
  69
+		}
  70
+	}
  71
+}
13  test/FluentCassandra.Tests/FluentCassandra.Tests.csproj
@@ -51,6 +51,7 @@
51 51
   </ItemGroup>
52 52
   <ItemGroup>
53 53
     <Compile Include="BigDecimalTest.cs" />
  54
+    <Compile Include="Bugs\Issue61SuperColumnRangeSliceKeyBackwards.cs" />
54 55
     <Compile Include="Bugs\Issue28GuidGeneratorInParallelContext.cs" />
55 56
     <Compile Include="Bugs\Issue25JavaBigDecimalBinaryConversion.cs" />
56 57
     <Compile Include="Bugs\Issue36KeyAliasSupport.cs" />
@@ -126,10 +127,10 @@
126 127
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
127 128
   <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
128 129
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
129  
-	   Other similar extension points exist, see Microsoft.Common.targets.
130  
-  <Target Name="BeforeBuild">
131  
-  </Target>
132  
-  <Target Name="AfterBuild">
133  
-  </Target>
134  
-  -->
  130
+  Other similar extension points exist, see Microsoft.Common.targets.
  131
+      <Target Name="BeforeBuild">
  132
+      </Target>
  133
+      <Target Name="AfterBuild">
  134
+      </Target>
  135
+      -->
135 136
 </Project>

0 notes on commit 8caa7bf

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