public void TestMapArgumentExceptions() { var map = new Customized32HashedMap <Order, Bill>(5, new MurmurHash32(), x => x.Id.ToString().ToBytes(), (x1, x2) => x1.Id == x2.Id); for (var i = 0; i < 5; i++) { var order = new Order() { Id = i, Name = Guid.NewGuid().ToString() }; map.Add(order, new Bill() { Id = i, Count = i }); } var notExistingOrder = new Order() { Id = 10, Name = Guid.NewGuid().ToString() }; Assert.Throws(typeof(KeyNotFoundException), () => { var v = map[notExistingOrder]; }); Assert.False(map.Remove(notExistingOrder)); var existingOrder = new Order() { Id = 1, Name = " " }; Assert.Throws(typeof(ArgumentException), () => map.Add(existingOrder, new Bill())); }
public void TestMapNullExceptions() { var map = new Customized32HashedMap <Order, Bill>(); Bill b; Assert.Throws(typeof(ArgumentNullException), () => map.Add(null, null)); Assert.Throws(typeof(ArgumentNullException), () => map[null] = null); Assert.Throws(typeof(ArgumentNullException), () => { var v = map[null]; }); Assert.Throws(typeof(ArgumentNullException), () => map.Remove(null)); Assert.Throws(typeof(ArgumentNullException), () => map.TryGetValue(null, out b)); Assert.Throws(typeof(ArgumentNullException), () => map.ContainsKey(null)); Assert.Throws(typeof(ArgumentNullException), () => map.CopyTo(null, 0)); var simpleMap = new Customized32HashedMap <int, string>(); simpleMap.Add(0, null); }