public void IsSynchronized() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); Assert.AreEqual(false, tkd.IsSynchronized); }
public void SerializationCheck() { TwoKeyDictionary <int, string, string> tkd = new TwoKeyDictionary <int, string, string>(); // load it up tkd.Add(33024, "LJ02-026XN-PEP2F-M88L", "7FwCTLnD0ZdnDmYRPbZW"); tkd.Add(66571, "LJ02-026XN-PEP2F-M88N", "Y4cE253SCT3agPC96Fhd"); tkd.Add(86280, "LJ02-026XN-PEP2F-M88T", "cGnsZLmKK8xKDQnCprKY"); tkd.Add(58647, "LJ02-026XN-PEP2F-M88R", "TWAggDF0jZVH454RRvrs"); tkd.Add(87303, "LJ02-026XN-PEP2F-M88Q", "TuGEgtXSm9WQ6JLFGGLW"); tkd.Add(86891, "LJ02-026XN-PEP2F-M88P", "ExmwnpRHWWx39dEkP6Ay"); tkd.Add(69992, "LJ02-026XN-PEP2F-M88M", "cQ6RNcQcEm1KFXqRkBth"); BinaryFormatter bf = new BinaryFormatter(); byte[] serializeA; byte[] serializeB; serializeA = ObjectToByteArray(tkd); serializeB = ObjectToByteArray(tkd); Object deserializeA = ByteArrayToObject(serializeA); Object deserializeB = ByteArrayToObject(serializeB); bool result = false; result = CompairStringDictionary(((TwoKeyDictionary <int, string, string>)deserializeA), tkd); Assert.AreEqual(true, result); result = CompairStringDictionary(((TwoKeyDictionary <int, string, string>)deserializeB), tkd); Assert.AreEqual(true, result); }
public static bool CompairStringDictionary(TwoKeyDictionary <int, string, string> src, TwoKeyDictionary <int, string, string> exp) { if (src.BKeys.Count != exp.BKeys.Count) { return(false); } string valueA; string valueB; foreach (TwoKeyValueTriple <int, string, string> item in exp) { if (src.TryGetValueKeyB(item.KeyB, out valueB)) { if (src.TryGetValueKeyA(item.KeyA, out valueA)) { if (valueA != item.Value || valueB != item.Value) { return(false); } } else { return(false); } } else { return(false); } } return(true); }
public void Count() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); Assert.AreEqual(POPSIZE, tkd.Count); }
public void TestAddDuplicate() { var dict = new TwoKeyDictionary <string, int, string>(); dict.Add("aaa", 0, "test"); dict.Add("aaa", 0, "oops"); }
public void TwoKeyDictionary_TwoKeyDictionary() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> seeder = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); TwoKeyDictionary <string, int, int> tkd = new TwoKeyDictionary <string, int, int>(seeder, null, null); Assert.AreEqual(11, tkd.Count, "main.Coun"); Assert.AreEqual(11, tkd.AKeys.Count, "main.AKeys.Count"); Assert.AreEqual(11, tkd.BKeys.Count, "main.BKeys.Count"); Assert.AreEqual(11, tkd.Values.Count, "main.Values.Count"); tkd.Add(ptkd.kavalues[11], ptkd.kbvalues[11], ptkd.vvalues[11]); tkd.Add(ptkd.kavalues[12], ptkd.kbvalues[12], ptkd.vvalues[12]); Assert.AreEqual(13, tkd.Count); Assert.AreEqual(13, tkd.AKeys.Count); Assert.AreEqual(13, tkd.BKeys.Count); Assert.AreEqual(13, tkd.Values.Count); int result = -1; result = tkd["AbaloneShell"]; Assert.AreEqual(-2373699, result); result = tkd[12]; Assert.AreEqual(-2373699, unchecked ((int)0xFFDBC7BD)); }
public void TwoKeyDictionary_Capacity_IEqualityComparerAB() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = new TwoKeyDictionary <string, int, int>(13, StringComparer.CurrentCultureIgnoreCase, new IntEqualityComparer()); for (int i = 0; i < 11; i++) { tkd.Add(ptkd.kavalues[i], ptkd.kbvalues[i], ptkd.vvalues[i]); } Assert.AreEqual(11, tkd.Count, "main.Coun"); Assert.AreEqual(11, tkd.AKeys.Count, "main.AKeys.Count"); Assert.AreEqual(11, tkd.BKeys.Count, "main.BKeys.Count"); Assert.AreEqual(11, tkd.Values.Count, "main.Values.Count"); tkd.Add(ptkd.kavalues[11], ptkd.kbvalues[11], ptkd.vvalues[11]); tkd.Add(ptkd.kavalues[12], ptkd.kbvalues[12], ptkd.vvalues[12]); Assert.AreEqual(13, tkd.Count); Assert.AreEqual(13, tkd.AKeys.Count); Assert.AreEqual(13, tkd.BKeys.Count); Assert.AreEqual(13, tkd.Values.Count); int result = -1; result = tkd["ABALONESHELL"]; Assert.AreEqual(-2373699, result); result = tkd[12]; Assert.AreEqual(-2373699, unchecked ((int)0xFFDBC7BD)); }
public void Remove_Object() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); TwoKeyValueTriple <string, int, int> src1 = new TwoKeyValueTriple <string, int, int>(ptkd.kavalues[3], ptkd.kbvalues[3], ptkd.vvalues[3]); TwoKeyValueTriple <string, int, int> src2 = new TwoKeyValueTriple <string, int, int>(ptkd.kavalues[6], ptkd.kbvalues[6], ptkd.vvalues[6]); tkd.Remove((object)src1.KeyA); if (tkd.Contains(src1.KeyA)) { Assert.Fail(); } if (!tkd.Contains(src1.KeyB)) { Assert.Pass(); } tkd.Remove((object)src2.KeyA); if (tkd.Contains(src1.KeyA)) { Assert.Fail(); } if (!tkd.Contains(src2.KeyB)) { Assert.Pass(); } }
private List <List <int> > MergeItem(List <List <int> > item_list) { TwoKeyDictionary <int, int, List <int> > map = new TwoKeyDictionary <int, int, List <int> >(); foreach (List <int> item_info in item_list) { int item_id = 0, count = 0, bind = 0, addition = 0; bool result = CustomFormat.ParseItemInfo(item_info, ref item_id, ref count, ref bind, ref addition); if (!result) { return(null); } List <int> info = map.Get(item_id, bind); if (info == null) { info = new List <int> { item_id, 0, bind, addition }; } info[2] += count; map.Set(item_id, bind, info); } return(map.ToList()); }
public void Contains_TwoKeyValueTriple() { List <TwoKeyValueTriple <string, int, int> > items = new List <TwoKeyValueTriple <string, int, int> >(); PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); for (int i = 0; i < POPSIZE; i++) { TwoKeyValueTriple <string, int, int> tkv = new TwoKeyValueTriple <string, int, int>(ptkd.kavalues[i], ptkd.kbvalues[i], ptkd.vvalues[i]); items.Add(tkv); } TwoKeyDictionary <string, int, int> tkd = new TwoKeyDictionary <string, int, int>(); for (int i = 0; i < items.Count; i++) { tkd.Add(items[i]); } for (int i = 0; i < POPSIZE; i++) { if (!tkd.Contains(items[i])) { Assert.Fail(); } } Assert.Pass(); }
public void CopyTo_TwoKeyValueTriple() { TwoKeyValueTriple <string, int, int>[] items = new TwoKeyValueTriple <string, int, int> [15]; PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); tkd.CopyTo(items, 0); int count = items.Length; }
public void TryGetValueKeyB() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); int result; tkd.TryGetValueKeyB(ptkd.kbvalues[6], out result); Assert.AreEqual(ptkd.vvalues[6], result); }
public void ContainsValue() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); if (!tkd.ContainsValue(ptkd.vvalues[9])) { Assert.Fail(); } }
public void TwoKeyDictionary_Capacity() { // can not directly check if initialize with given capacity but // should upon completing initialization have known default settings. TwoKeyDictionary <int, int, int> tkd = new TwoKeyDictionary <int, int, int>(7); Assert.AreEqual(0, tkd.Count); Assert.AreEqual(0, tkd.Values.Count); Assert.AreEqual(0, tkd.AKeys.Count); Assert.AreEqual(0, tkd.BKeys.Count); }
public TwoKeyDictionary <string, int, int> GetLoadedTwoKeyDictionary(int size) { TwoKeyDictionary <string, int, int> tkd = new TwoKeyDictionary <string, int, int>(); for (int i = 0; i < size; i++) { tkd.Add(kavalues[i], kbvalues[i], vvalues[i]); } return(tkd); }
public void gettable_tcno_spec_id_band(string spec) { //tc_band_sheet = new TwoKeyDictionary<string, string, string>(); tc_band_id = new TwoKeyDictionary <string, string, string>(); tc_band_status = new TwoKeyDictionary <string, string, string>(); tc_bandapplicability = new _Dictionary <string, string>(); tc_des = new _Dictionary <string, string>(); try { dbobj.tablename = "v_comb_serv_info"; string Conditionstring = String.Format("(spec = \"{0}\" and ver_gcf_ptcrb_op = \"{1}\")", spec, gcfver); List <string> colnames = new List <string>() { "testcase", "band", "id", "bandapplicability", "tcstatus", "sheetname", "Description" }; DataTable retdt = dbobj.getdatatble(colnames, Conditionstring); foreach (DataRow row in retdt.Rows) { string tcno = row[0].ToString().Replace(" ", "").ToLower(); if (tc_band_id.ContainsKey(tcno, row[1].ToString())) { //lgstr.cri(String.Format("{GenericParser:gettable_tcno_spec_id_band} duplicate of {0} and {1} found in spec {2} ", row[0].ToString(), row[1].ToString(), spec)); lgstr.cri("{ FORMUpload:gettable_tcno_spec_id_band} duplicate tc/band combination. TC: " + tcno + " Band: " + row[1].ToString()); } if (!tc_bandapplicability.ContainsKey(tcno)) { tc_bandapplicability[tcno] = row[3].ToString(); } if (!tc_des.ContainsKey(tcno)) { tc_des[tcno] = row[6].ToString(); } tc_band_id[tcno, row[1].ToString()] = row[2].ToString(); tc_band_status[tcno, row[1].ToString()] = row[4].ToString(); //tc_band_sheet[tcno, row[1].ToString()] = row[5].ToString(); } //lgstr.inf("tc_bandapplicability"); //lgstr.inf(tc_bandapplicability.ToString()); //lgstr.inf("tcbandstatus"); //lgstr.inf(tc_band_status.ToString()); } catch (Exception ex) { Debug.Print("Exception from gettable : " + ex.ToString()); lg.war("{FORMUpload:gettable_tcno_spec_id_band} Exception: " + ex.Message.ToString()); } //return tc_band_id; }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { string navPath = this.fileOpenControl_ephe.FilePath; string directory = this.directorySelectionControl1.Path; var cutOffAngle = namedFloatControl_cutOffAnlgle.Value; var gridLooper = geoGridLoopControl1.GetGridLooper(); var timeLooper = timeLoopControl1.GetTimeLooper(); string satWeightPath = fileOpenControl_prnWeight.FilePath; var SatWeightData = new TwoKeyDictionary <Time, SatelliteNumber, double>(); SatWeightTable SatWeights = null; if (System.IO.File.Exists(satWeightPath)) { var reader = new ObjectTableReader(satWeightPath); var data = reader.Read(); SatWeights = new SatWeightTable(data, 730 * 24 * 3600, "Epoch", "PRN", "Weight"); SatWeights.Init(); log.Info("载入卫星权值文件 : " + satWeightPath); } else { log.Info("没有卫星权值文件"); } IEphemerisService EphemerisService = EphemerisDataSourceFactory.Create(navPath); var satTypes = multiGnssSystemSelectControl1.SatelliteTypes; List <SatelliteNumber> EnabledPrns = EphemerisService.Prns.FindAll(m => satTypes.Contains(m.SatelliteType)); if (EnabledPrns.Count == 0) { Geo.Utils.FormUtil.ShowWarningMessageBox("所选系统星历卫星数量为 0 ."); return; } EnabledPrns.Sort(); log.Info("当前系统:" + Geo.Utils.EnumerableUtil.ToString(satTypes) + ",卫星数量:" + EnabledPrns.Count + ", " + Geo.Utils.EnumerableUtil.ToString(EnabledPrns)); DopSolver = new DopSolver(EphemerisService, cutOffAngle, directory, EnabledPrns, SatWeights, timeLooper, gridLooper); DopSolver.IsSimpleModel = checkBox1IsSimpleModel.Checked; if (enabledFloatControl1maxDop.Enabled) { DopSolver.MaxDopThreshold = enabledFloatControl1maxDop.Value; } DopSolver.TimeLooper.ProgressViewer = progressBarComponent1; DopSolver.SolveAsync(); Geo.Utils.FormUtil.ShowOkAndOpenDirectory(directory); }
public void RemoveKeyB() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); if (!tkd.RemoveKeyB(ptkd.kbvalues[5])) { Assert.Fail(); } if (!tkd.Contains(ptkd.kavalues[5])) { Assert.Pass(); } }
public void IEnumerable_GetEnumerator() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); foreach (TwoKeyValueTriple <string, int, int> tkvt in tkd) { if (!tkd.ContainsKeyA(tkvt.KeyA)) { Assert.Fail(); } } Assert.Pass(); }
public void TwoKeyDictionary_Base() { // basic check of an instance of an object with default settings. TwoKeyDictionary <int, int, int> tkd = new TwoKeyDictionary <int, int, int>(); TwoKeyDictionary <string, string, string> tkd2 = new TwoKeyDictionary <string, string, string>(); Assert.AreEqual(0, tkd.Count); Assert.AreEqual(0, tkd2.Count); Assert.AreEqual(0, tkd.Values.Count); Assert.AreEqual(0, tkd2.Values.Count); Assert.AreEqual(0, tkd.AKeys.Count); Assert.AreEqual(0, tkd.BKeys.Count); Assert.AreEqual(0, tkd2.AKeys.Count); Assert.AreEqual(0, tkd2.BKeys.Count); }
public void Add() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); foreach (string akey in tkd.AKeys) { if (!tkd.ContainsKeyA(akey)) { Assert.Fail(); } } Assert.Pass(); }
public void TValue_TKeyB_Key() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); for (int i = 0; i < POPSIZE; i++) { if (ptkd.vvalues[i] != tkd[ptkd.kbvalues[i]]) { Assert.Fail(); } } Assert.Pass(); }
private void setup() { Locations = new TwoKeyDictionary <string, string, string>(); config_files = collectConfigFiles(); foreach (String user in config_files.Keys) { IniFileHandler ini = new IniFileHandler(config_files[user]); foreach (string section in ini.Keys) { if (ini[section].ContainsKey("savepath")) { Locations.Add(user, section, ini[section]["savepath"]); } } } install_path = findInstallPath(); }
public void Contains_Object() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); object keya = ptkd.kavalues[3]; object keyb = ptkd.kbvalues[6]; if (!tkd.Contains(keya)) { Assert.Fail(); } if (!tkd.Contains(keyb)) { Assert.Fail(); } }
private static TwoKeyDictionary <string, int, string> CreateDict() { TwoKeyDictionary <string, int, string> dict = new TwoKeyDictionary <string, int, string>(); dict.Add("aaa", 0, "x"); dict.Add("aaa", 1, "y"); dict.Add("aaa", 2, "z"); dict.Add("bbb", 0, "test 1"); dict.Add("bbb", 10, "test 2"); dict.Add("bbb", 20, "test 3"); dict.Add("bbb", 30, "test 4"); dict.Add("ccc", -5, ""); dict.Add("", 0, ""); return(dict); }
public void ICollection_TKeyA() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); ICollection <string> ika = tkd.AKeys; Assert.AreEqual(tkd.Count, ika.Count); foreach (string akey in ika) { if (!tkd.ContainsKeyA(akey)) { Assert.Fail(); } } Assert.Pass(); }
public void TwoKeyDictionary_TwoKeyDictionary_IEqualityComparerAB() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> seeder = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); TwoKeyDictionary <string, int, int> tkd = new TwoKeyDictionary <string, int, int>(seeder, StringComparer.CurrentCultureIgnoreCase, new IntEqualityComparer()); Assert.AreEqual(11, tkd.Count, "main.Coun"); Assert.AreEqual(11, tkd.AKeys.Count, "main.AKeys.Count"); Assert.AreEqual(11, tkd.BKeys.Count, "main.BKeys.Count"); Assert.AreEqual(11, tkd.Values.Count, "main.Values.Count"); tkd.Add(ptkd.kavalues[11], ptkd.kbvalues[11], ptkd.vvalues[11]); tkd.Add(ptkd.kavalues[12], ptkd.kbvalues[12], ptkd.vvalues[12]); Assert.AreEqual(13, tkd.Count); Assert.AreEqual(13, tkd.AKeys.Count); Assert.AreEqual(13, tkd.BKeys.Count); Assert.AreEqual(13, tkd.Values.Count); }
public void ICollection_TValue() { PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); TwoKeyDictionary <string, int, int> tkd = ptkd.GetLoadedTwoKeyDictionary(POPSIZE); ICollection <int> ikb = tkd.Values; Assert.AreEqual(tkd.Count, ikb.Count); foreach (int bkey in ikb) { if (!tkd.ContainsValue(bkey)) { Assert.Fail(); } } Assert.Pass(); }
public void Add_TwoKeyValueTriple() { List <TwoKeyValueTriple <string, int, int> > items = new List <TwoKeyValueTriple <string, int, int> >(); PackTwoKeyDictionary ptkd = new PackTwoKeyDictionary(); for (int i = 0; i < POPSIZE; i++) { TwoKeyValueTriple <string, int, int> tkv = new TwoKeyValueTriple <string, int, int>(ptkd.kavalues[i], ptkd.kbvalues[i], ptkd.vvalues[i]); items.Add(tkv); } TwoKeyDictionary <string, int, int> tkd = new TwoKeyDictionary <string, int, int>(); for (int i = 0; i < items.Count; i++) { tkd.Add(items[i]); } Assert.AreEqual(items.Count, tkd.Count); }
public void SyncRoot() { TwoKeyDictionary <string, int, int> stkd = sptkd.GetLoadedTwoKeyDictionary(POPSIZE); _items = stkd.BKeys; lock (stkd.SyncRoot) { stkd.Add(sptkd.kavalues[12], sptkd.kbvalues[12], sptkd.vvalues[12]); foreach (int item in _items) { Console.WriteLine("main thread " + item); _result.Add("main thread " + item); } } Assert.AreEqual(12, _result.Count); Assert.AreEqual("main thread 0", _result[0]); Assert.AreEqual("main thread 12", _result[11]); }
private void setup() { Locations = new TwoKeyDictionary<string, string, string>(); config_files = collectConfigFiles(); foreach (String user in config_files.Keys) { IniFileHandler ini = new IniFileHandler(config_files[user]); foreach (string section in ini.Keys) { if (ini[section].ContainsKey("savepath")) { Locations.Add(user, section, ini[section]["savepath"]); } } } install_path = findInstallPath(); }
public void TwoKeyDictionaryTestSetUp() { string[] firstKeyStrings = { "a", "b" }; int[] secondKeyInts = { 1, 2, 3 }; _dictionary = new TwoKeyDictionary<string, int, double>(firstKeyStrings, secondKeyInts); _dictionary["a", 1] = 1D; _dictionary["a", 2] = 2D; _dictionary["a", 3] = 3D; _dictionary["b", 1] = 4D; _dictionary["b", 2] = 5D; _dictionary["b", 3] = 6D; }
public void TwoKeyDictionaryTestTearDown() { _dictionary = null; }