public void AddVariousKeyClass() { Converts.Repository .AddStringTo <Guid>(Guid.TryParse); IKeyToParametersConverter converter = CreateConverter(); KeyValueCollection parameters = new KeyValueCollection(); converter.Add(parameters, Int32Key.Create(5, "Product")); Assert.AreEqual(2, parameters.Keys.Count()); Assert.AreEqual(5, parameters.Get <int>("ID")); Assert.AreEqual("Product", parameters.Get <string>("Type")); parameters = new KeyValueCollection(); converter.Add(parameters, StringKey.Create("abcdef", "Product")); Assert.AreEqual(2, parameters.Keys.Count()); Assert.AreEqual("abcdef", parameters.Get <string>("Identifier")); Assert.AreEqual("Product", parameters.Get <string>("Type")); parameters = new KeyValueCollection(); Guid guid = Guid.NewGuid(); converter.Add(parameters, GuidKey.Create(guid, "Product")); Assert.AreEqual(2, parameters.Keys.Count()); Assert.AreEqual(guid, parameters.Get <Guid>("Guid")); Assert.AreEqual("Product", parameters.Get <string>("Type")); }
public void AddPrefix() { IKeyToParametersConverter converter = CreateConverter(); KeyValueCollection parameters = new KeyValueCollection(); converter.Add(parameters, "Source", Int32Key.Create(5, "Product")); converter.Add(parameters, "Target", Int32Key.Create(8, "Product")); Assert.AreEqual(4, parameters.Keys.Count()); Assert.AreEqual(5, parameters.Get <int>("SourceID")); Assert.AreEqual("Product", parameters.Get <string>("SourceType")); Assert.AreEqual(8, parameters.Get <int>("TargetID")); Assert.AreEqual("Product", parameters.Get <string>("TargetType")); }