예제 #1
0
        public void StandardObject()
        {
            var valueMapper = new ValueMapper();

            var myObj  = new object();
            var id     = valueMapper.GetID(myObj);
            var myObj2 = valueMapper.GetObject(id);

            Assert.AreSame(myObj, myObj2);
        }
예제 #2
0
        public void NullHandling()
        {
            var valueMapper = new ValueMapper();

            var id = valueMapper.GetID(null);

            var obj = valueMapper.GetObject(id);

            Assert.IsNull(obj);
        }
예제 #3
0
        public object GetErrorKey(string axisName)
        {
            for (int i = 0; i < _axisNames.Length; i++)
            {
                if (_errorKeys [i].HasValue &&
                    _axisNames [i] == axisName)
                {
                    return(_valueMapper.GetObject(_errorKeys [i].Value));
                }
            }

            throw new InvalidOperationException($"No error key found for axis '{axisName}'");
        }
예제 #4
0
        public void StandardObjectAndNull()
        {
            var valueMapper = new ValueMapper();

            var myObj  = new object();
            var id     = valueMapper.GetID(myObj);
            var nullID = valueMapper.GetID(null);
            var myObj2 = valueMapper.GetObject(id);

            Assert.AreSame(myObj, myObj2);

            Assert.AreNotEqual(nullID, id);
        }
예제 #5
0
        public void ProcessLargeNumbers()
        {
            var valueMapper = new ValueMapper();
            var dict        = new Dictionary <string, uint>();

            for (int i = 0; i < 2000000; i++)
            {
                string s = i.ToString();
                dict [s] = valueMapper.GetID(s);
            }

            foreach (var kvp in dict)
            {
                var returnedID = valueMapper.GetID(kvp.Key);

                Assert.AreEqual(kvp.Value, returnedID);
                Assert.AreEqual(kvp.Key, valueMapper.GetObject(returnedID));
            }
        }