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 Int32Key_Ordering() { Int32Key key1 = Int32Key.Create(1, "Product"); Int32Key key2 = Int32Key.Create(2, "Product"); Int32Key key3 = Int32Key.Create(3, "Product"); Int32Key key4 = Int32Key.Create(4, "Product"); Int32Key key5 = Int32Key.Create(1, "Term"); Int32Key key6 = Int32Key.Create(2, "Term"); Int32Key key7 = Int32Key.Create(3, "Term"); Int32Key key8 = Int32Key.Create(4, "Term"); List <Int32Key> list = new List <Int32Key>() { key5, key4, key3, key7, key6, key8, key1, key2 }; list.Sort(); Assert.AreEqual(list[0], Int32Key.Create(1, "Product")); Assert.AreEqual(list[1], Int32Key.Create(2, "Product")); Assert.AreEqual(list[2], Int32Key.Create(3, "Product")); Assert.AreEqual(list[3], Int32Key.Create(4, "Product")); Assert.AreEqual(list[4], Int32Key.Create(1, "Term")); Assert.AreEqual(list[5], Int32Key.Create(2, "Term")); Assert.AreEqual(list[6], Int32Key.Create(3, "Term")); Assert.AreEqual(list[7], Int32Key.Create(4, "Term")); }
public void AddWithoutType() { IKeyToParametersConverter converter = CreateConverter(); KeyValueCollection parameters = new KeyValueCollection(); converter.AddWithoutType(parameters, Int32Key.Create(5, "Product")); Assert.AreEqual(1, parameters.Keys.Count()); Assert.AreEqual(5, parameters.Get <int>("ID")); }
public void AddPrefixWithoutType() { IKeyToParametersConverter converter = CreateConverter(); KeyValueCollection parameters = new KeyValueCollection(); converter.AddWithoutType(parameters, "Source", Int32Key.Create(5, "Product")); converter.AddWithoutType(parameters, "Target", Int32Key.Create(8, "Product")); Assert.AreEqual(2, parameters.Keys.Count()); Assert.AreEqual(5, parameters.Get <int>("SourceID")); Assert.AreEqual(8, parameters.Get <int>("TargetID")); }
public void Int32Key_Equal() { Int32Key key1 = Int32Key.Create(1, "Product"); Int32Key key2 = Int32Key.Create(1, "Product"); Assert.AreEqual(key1, key2); key1 = Int32Key.Create(1, "Product"); key2 = Int32Key.Create(2, "Product"); Assert.AreNotEqual(key1, key2); key1 = Int32Key.Create(1, "Product"); key2 = Int32Key.Create(1, "Term"); Assert.AreNotEqual(key1, key2); }
public void ThrowMissingKeyClassToParametersMappingException() { IKeyToParametersConverter converter = new KeyToParametersConverter(new KeyToParametersConverter.MappingCollection()); converter.Add(new KeyValueCollection(), Int32Key.Create(5, "Product")); }