Exemple #1
0
        public void SymbolIsDefaultTest()
        {
            Symbol testObj = new Symbol ();

            testObj.IsDefault = true;

            Assert.AreEqual (true, testObj.IsDefault);
        }
Exemple #2
0
        public void SymbolIDTest()
        {
            Symbol testObj = new Symbol ();

            testObj.Id = 99;

            Assert.AreEqual (99, testObj.Id);
        }
Exemple #3
0
        public void SymbolNewEfUnitSymbolUnitTest()
        {
            Unit unitObj = new Unit {
                ID = 99,
                Name = "Name"
            };
            Symbol testObj = new Symbol (unitObj);

            Assert.IsNotNull (testObj);

            Assert.IsTrue (string.IsNullOrEmpty (testObj.Value));

            Assert.IsNotNull (testObj.Unit);
            Assert.IsTrue (testObj.Unit.ID == unitObj.ID);
        }
Exemple #4
0
        private void ProcessUnitConverterData2(Cubico.UnitData.RootObject RootObject)
        {
            var data = RootObject.UnitConverterData;
            //Load Modifier Data
            _individualModifiers = new Dictionary<int, List<Modifier>>();
            foreach (var itm in data.UnitModifiers.UnitModifier)
            {
                var mod = new Modifier();
                mod.ID = Convert.ToInt32(itm.ID);
                mod.Value = Convert.ToDecimal(itm.Value);
                mod.Order = Convert.ToInt32(itm.Order);
                mod.ModifierType = (ModifierType)Convert.ToInt32(itm.ModifierID);
                mod.UnitSourceID = Convert.ToInt32(itm.UnitSourceID);
                mod.UnitTargetID = Convert.ToInt32(itm.UnitTargetID);

                if (string.IsNullOrWhiteSpace(itm.Precision))
                {
                    mod.Precision = null;
                }
                else
                {
                    mod.Precision = Convert.ToInt32(itm.Precision);
                }

                if (_individualModifiers.ContainsKey(mod.UnitTargetID))
                {
                    var modList = _individualModifiers[mod.UnitTargetID];
                    modList.Add(mod);
                }
                else
                {
                    var modList = new List<Modifier> { mod };
                    _individualModifiers.Add(mod.UnitTargetID, modList);
                }
            }

            //Load Symbol Data
            _symbolLookUp = new Dictionary<int, List<Symbol>>();
            foreach (var itm in data.Symbols.UnitSymbol)
            {
                var sym = new Symbol();
                sym.Id = Convert.ToInt32(itm.ID);
                sym.Value = itm.Symbol;
                sym.UnitId = Convert.ToInt32(itm.UnitID);
                int value = Convert.ToInt32(itm.IsDefault);
                if (value == 1)
                    sym.IsDefault = true;
                else
                    sym.IsDefault = false;

                if (_symbolLookUp.ContainsKey(sym.UnitId))
                {
                    var symList = _symbolLookUp[sym.UnitId];
                    symList.Add(sym);
                }
                else
                {
                    var symList = new List<Symbol> { sym };
                    _symbolLookUp.Add(sym.UnitId, symList);
                }
            }

            _units = new Dictionary<string, Unit>();
            foreach (var itm in data.Units.Unit)
            {
                var unit = new Unit();
                unit.ID = Convert.ToInt32(itm.ID);
                unit.Name = itm.Name;
                unit.UnitTypeID = Convert.ToInt32(itm.UnitTypeID);

                if (_symbolLookUp.ContainsKey(unit.ID))
                {
                    unit.Symbols = _symbolLookUp[unit.ID];

                    foreach (Symbol sym in unit.Symbols)
                    {
                        sym.Unit = unit;
                    }
                }
                if (_individualModifiers.ContainsKey(unit.ID))
                {
                    unit.Modifiers = _individualModifiers[unit.ID];

                    foreach (Modifier mod in unit.Modifiers)
                    {
                        mod.ParentUnit = unit;
                    }
                }
                _units.Add(unit.Name, unit);
            }

            //Load Unit Types
            _unitTypes = new Dictionary<string, UnitType>();
            foreach (var itm in data.UnitTypes.UnitType)
            {
                var ut = new UnitType();
                ut.ID = Convert.ToInt32(itm.ID);
                ut.Name = itm.Name;
                ut.Description = itm.Description;

                // Make this a for loop for speed reasons or use a multikey dictionary.
                var unitData = (from unit in _units.Values
                                where unit.UnitTypeID == ut.ID
                                select unit).ToList();
                ut.Units = unitData;

                foreach (Unit unitItem in ut.Units)
                {
                    unitItem.UnitType = ut;
                }

                _unitTypes.Add(ut.Name, ut);
            }
        }
Exemple #5
0
		public bool Equals (Symbol other)
		{
			if ((object)other == null) {
				return false;
			} else {
				if (this.Value != other.Value) {
					return false;
				} else {
					return true;
				}
			}
		}
Exemple #6
0
        public void SymbolParentUnitNullTest()
        {
            Symbol testObj = new Symbol ();

            testObj.Unit = null;

            Assert.IsNull (testObj.Unit);
        }
Exemple #7
0
        public void SymbolNewTest()
        {
            Symbol testObj = new Symbol ();

            Assert.IsNotNull (testObj);
            Assert.IsTrue (testObj.Id == 0);
            Assert.IsTrue (testObj.Value == null);
            Assert.IsNull (testObj.Unit);
        }
Exemple #8
0
 public void SymbolNewEfUnitSymbolUnitNullTest()
 {
     Symbol testObj = new Symbol ();
     Assert.IsFalse(testObj.Equals (null));
 }
Exemple #9
0
        public void SymbolIDNullTest()
        {
            Symbol testObj = new Symbol ();

            Assert.AreEqual (0, testObj.Id);
        }
Exemple #10
0
        public void SymbolValueTest()
        {
            Symbol testObj = new Symbol ();

            testObj.Value = "Test Name";

            Assert.AreEqual ("Test Name", testObj.Value);
        }
Exemple #11
0
        public void SymbolParentUnitTest()
        {
            Unit testUnitObj = new Unit ();
            Symbol testObj = new Symbol (testUnitObj);
            testObj.Unit = testUnitObj;

            Assert.IsNotNull (testObj.Unit);
            Assert.AreEqual (testUnitObj.ID, testObj.Unit.ID);
            Assert.AreEqual (testUnitObj.Name, testObj.Unit.Name);
        }