Permalink
Browse files

fixed #108 and for #107 everything except 29 tests now pass

  • Loading branch information...
1 parent 4f7faa3 commit a428fdadab808c7a6d639af12b4175b9f8654845 @nberardi nberardi committed Jan 25, 2013
View
@@ -97,13 +97,48 @@ public static byte[] GenerateNodeBytes(PhysicalAddress mac)
return node;
}
+ /// <summary>
+ /// Generates a random clock sequence.
+ /// </summary>
public static byte[] GenerateClockSequenceBytes()
{
var bytes = new byte[2];
Random.NextBytes(bytes);
return bytes;
}
+ /// <summary>
+ /// In order to maintain a constant value we need to get a two byte hash from the DateTime.
+ /// </summary>
+ public static byte[] GenerateClockSequenceBytes(DateTime dt)
+ {
+ var bytes = BitConverter.GetBytes(dt.Ticks);
+
+ if (bytes.Length == 0)
+ return new byte[] { 0x0, 0x0 };
+
+ if (bytes.Length == 1)
+ return new byte[] { 0x0, bytes[0] };
+
+ return new byte[] { bytes[0], bytes[1] };
+ }
+
+ /// <summary>
+ /// In order to maintain a constant value we need to get a two byte hash from the DateTime.
+ /// </summary>
+ public static byte[] GenerateClockSequenceBytes(DateTimeOffset dt)
+ {
+ var bytes = BitConverter.GetBytes(dt.Ticks);
+
+ if (bytes.Length == 0)
+ return new byte[] { 0x0, 0x0 };
+
+ if (bytes.Length == 1)
+ return new byte[] { 0x0, bytes[0] };
+
+ return new byte[] { bytes[0], bytes[1] };
+ }
+
public static GuidVersion GetUuidVersion(this Guid guid)
{
byte[] bytes = guid.ToByteArray();
@@ -167,32 +202,32 @@ public static Guid GenerateTimeBasedGuid()
public static Guid GenerateTimeBasedGuid(DateTime dateTime)
{
- return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(), NodeBytes);
+ return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(dateTime), NodeBytes);
}
public static Guid GenerateTimeBasedGuid(DateTimeOffset dateTime)
{
- return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(), NodeBytes);
+ return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(dateTime), NodeBytes);
}
public static Guid GenerateTimeBasedGuid(DateTime dateTime, PhysicalAddress mac)
{
- return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(), GenerateNodeBytes(mac));
+ return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(dateTime), GenerateNodeBytes(mac));
}
public static Guid GenerateTimeBasedGuid(DateTimeOffset dateTime, PhysicalAddress mac)
{
- return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(), GenerateNodeBytes(mac));
+ return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(dateTime), GenerateNodeBytes(mac));
}
public static Guid GenerateTimeBasedGuid(DateTime dateTime, IPAddress ip)
{
- return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(), GenerateNodeBytes(ip));
+ return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(dateTime), GenerateNodeBytes(ip));
}
public static Guid GenerateTimeBasedGuid(DateTimeOffset dateTime, IPAddress ip)
{
- return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(), GenerateNodeBytes(ip));
+ return GenerateTimeBasedGuid(dateTime, GenerateClockSequenceBytes(dateTime), GenerateNodeBytes(ip));
}
public static Guid GenerateTimeBasedGuid(DateTime dateTime, byte[] clockSequence, byte[] node)
@@ -24,10 +24,10 @@ public override FluentColumn Execute()
};
if (SuperColumnName != null)
- path.SuperColumn = SuperColumnName.GetValue(schema.SuperColumnNameType) as CassandraObject;
+ path.SuperColumn = SuperColumnName.GetValue(schema.SuperColumnNameType);
if (ColumnName != null)
- path.Column = ColumnName.GetValue(schema.ColumnNameType) as CassandraObject;
+ path.Column = ColumnName.GetValue(schema.ColumnNameType);
var output = Session.GetClient().get(
Key,
@@ -27,7 +27,7 @@ public void Save_Guid()
{
// arrange
var family = _db.GetColumnFamily<TimeUUIDType>(FamilyName);
- Guid expected = new Guid("38400000-8cf0-11bd-b23e-10b96e4ef00d");
+ var expected = new Guid("38400000-8cf0-11bd-b23e-10b96e4ef00d");
// act
family.InsertColumn(TestKey, expected, Math.PI);

0 comments on commit a428fda

Please sign in to comment.