Exemplo n.º 1
0
        public CubePoint(ValueMapper valueMapper, KeyValuePair <uint [], TValueType> kvp)
        {
            if (valueMapper == null)
            {
                throw new ArgumentNullException(nameof(valueMapper));
            }

            this._valueMapper = valueMapper;
            this._kvp         = kvp;
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void NullHandling()
        {
            var valueMapper = new ValueMapper();

            var id = valueMapper.GetID(null);

            var obj = valueMapper.GetObject(id);

            Assert.IsNull(obj);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new instance of the error.
        /// </summary>
        /// <remarks>This method will take a reference to the existing <paramref name="valueMapper"/> and
        /// <paramref name="axisNames"/> parameters, but will copy the <paramref name="errorKeys"/> array.
        /// This is necessary to simplify the initial construction of the underlying array</remarks>
        /// <param name="valueMapper"></param>
        /// <param name="axisNames"></param>
        /// <param name="errorKeys"></param>
        /// <param name="errorMessage"></param>
        public Error(ValueMapper valueMapper, string [] axisNames, uint? [] errorKeys, string errorMessage)
        {
            _valueMapper      = valueMapper;
            _axisNames        = axisNames;
            this.ErrorMessage = errorMessage;

            _errorKeys = new uint? [errorKeys.Length];
            for (int i = 0; i < errorKeys.Length; i++)
            {
                _errorKeys [i] = errorKeys [i];
            }
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new instance of <see cref="ErrorSet"/>
        /// </summary>
        /// <param name="valueMapper">The value mapper to use to encode values</param>
        /// <param name="axisNames">THe set of axes that can be used to key errors on</param>
        public ErrorSet(ValueMapper valueMapper, string [] axisNames)
        {
            if (valueMapper == null)
            {
                throw new ArgumentNullException(nameof(valueMapper));
            }

            if (axisNames == null)
            {
                throw new ArgumentNullException(nameof(axisNames));
            }

            this._valueMapper = valueMapper;
            this._axisNames   = axisNames;

            this._errorsDictionary = new Dictionary.HybridErrorsDictionary(_axisNames);
        }
Exemplo n.º 7
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));
            }
        }