private void TestShardKeyGeneric <TKey>(ShardKeyType keyType, TKey inputValue, Type realType) { // Excercise DetectType // ShardKey k1 = new ShardKey(inputValue); Assert.AreEqual(realType, k1.DataType); // Go to/from raw value ShardKey k2 = new ShardKey(keyType, inputValue); byte[] k2raw = k2.RawValue; ShardKey k3 = ShardKey.FromRawValue(keyType, k2raw); Assert.AreEqual(inputValue, k2.Value); Assert.AreEqual(inputValue, k3.Value); Assert.AreEqual(k2, k3); // verify comparisons Assert.AreEqual(0, k2.CompareTo(k3)); try { k3 = k2.GetNextKey(); Assert.IsTrue(k3 > k2); } catch (InvalidOperationException) { } }