public void Test_TypedKeySpace_T1() { var location = KeySubspace.CreateTyped <string>(Slice.FromString("PREFIX")); Assert.That(location.KeyEncoder, Is.Not.Null, "Should have a Key Encoder"); Assert.That(location.KeyEncoder.Encoding, Is.SameAs(TuPack.Encoding), "Encoder should use Tuple type system"); // shortcuts Assert.That(location[Slice.FromString("SUFFIX")].ToString(), Is.EqualTo("PREFIXSUFFIX")); Assert.That(location.Keys["hello"].ToString(), Is.EqualTo("PREFIX<02>hello<00>")); Assert.That(location.Keys[ValueTuple.Create("hello")].ToString(), Is.EqualTo("PREFIX<02>hello<00>")); // Encode<T...>(...) Assert.That(location.Keys.Encode("hello").ToString(), Is.EqualTo("PREFIX<02>hello<00>")); // Pack(ITuple) Assert.That(location.Keys.Pack((ITuple)STuple.Create("hello")).ToString(), Is.EqualTo("PREFIX<02>hello<00>")); // Pack(ValueTuple) Assert.That(location.Keys.Pack(ValueTuple.Create("hello")).ToString(), Is.EqualTo("PREFIX<02>hello<00>")); // STuple<T...> Decode(...) Assert.That(location.Keys.Decode(Slice.Unescape("PREFIX<02>hello<00>")), Is.EqualTo("hello")); // Decode(..., out T) location.Keys.Decode(Slice.Unescape("PREFIX<02>hello<00>"), out string x); Assert.That(x, Is.EqualTo("hello")); }
public void Test_TypedKeySpace_T2() { var location = KeySubspace.CreateTyped <string, int>(Slice.FromString("PREFIX")); // shortcuts Assert.That(location[Slice.FromString("SUFFIX")].ToString(), Is.EqualTo("PREFIXSUFFIX")); Assert.That(location.Keys["hello", 123].ToString(), Is.EqualTo("PREFIX<02>hello<00><15>{")); Assert.That(location.Keys[("hello", 123)].ToString(), Is.EqualTo("PREFIX<02>hello<00><15>{"));