Skip to content
Browse files

Added test to verify fix of issue #61.

  • Loading branch information...
1 parent 242daad commit 8caa7bfcb8b96d701313fbd63d7185a26e3accf5 @smerchek committed Sep 5, 2012
View
71 test/FluentCassandra.Tests/Bugs/Issue61SuperColumnRangeSliceKeyBackwards.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FluentCassandra.Types;
+using Xunit;
+
+namespace FluentCassandra.Bugs
+{
+ public class Issue61SuperColumnRangeSliceKeyBackwards : IUseFixture<CassandraDatabaseSetupFixture>, IDisposable
+ {
+ private CassandraContext _db;
+
+ public void SetFixture(CassandraDatabaseSetupFixture data)
+ {
+ var setup = data.DatabaseSetup();
+ _db = setup.DB;
+ }
+
+ public void Dispose()
+ {
+ _db.Dispose();
+ }
+
+ [Fact]
+ public void Test_GetRangeSlice()
+ {
+ // arrange
+ var keyspace = _db.Keyspace;
+
+ // create column family using API
+ _db.TryDropColumnFamily("supercolumns");
+
+ keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema
+ {
+ FamilyName = "supercolumns",
+ FamilyType = ColumnType.Super,
+ KeyValueType = CassandraType.UTF8Type,
+ SuperColumnNameType = CassandraType.TimeUUIDType,
+ ColumnNameType = CassandraType.UTF8Type,
+ DefaultColumnValueType = CassandraType.UTF8Type
+ });
+
+ InsertData("testKey");
+
+ // act
+ var actual = _db.GetSuperColumnFamily("supercolumns").Get().TakeKeys(5);
+
+ // assert
+ Assert.NotNull(actual);
+ Assert.Equal(1, actual.Count());
+ Assert.Equal("testKey", actual.First().Key.ToString());
+ }
+
+ public void InsertData(string key)
+ {
+ var productFamily = _db.GetSuperColumnFamily("supercolumns");
+
+ var post = productFamily.CreateRecord(key);
+ _db.Attach(post);
+
+ for (int i = 0; i < 4; i++)
+ {
+ dynamic d = post.CreateSuperColumn(GuidGenerator.GenerateTimeBasedGuid(DateTimeOffset.Now.Subtract(TimeSpan.FromSeconds(i))));
+ d.columnone = Guid.NewGuid().ToString();
+ d.columntwo = Guid.NewGuid().ToString();
+ }
+
+ _db.SaveChanges();
+ }
+ }
+}
View
13 test/FluentCassandra.Tests/FluentCassandra.Tests.csproj
@@ -51,6 +51,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BigDecimalTest.cs" />
+ <Compile Include="Bugs\Issue61SuperColumnRangeSliceKeyBackwards.cs" />
<Compile Include="Bugs\Issue28GuidGeneratorInParallelContext.cs" />
<Compile Include="Bugs\Issue25JavaBigDecimalBinaryConversion.cs" />
<Compile Include="Bugs\Issue36KeyAliasSupport.cs" />
@@ -126,10 +127,10 @@
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
</Project>

0 comments on commit 8caa7bf

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