Exemplo n.º 1
0
        // provide access to Tuning items


        /// <summary>
        /// Returns a tuning item for the asked option
        /// </summary>
        /// <param name="optionName">The option to get</param>
        /// <returns>A DeviceTuning item or null if it does not exist</returns>
        public DeviceTuningParameter TuningItem(string optionName)
        {
            if (m_tuning.ContainsKey(optionName))
            {
                return(m_tuning[optionName]);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        private void DictionaryTests(CloneableDictionary <string, Person> dut)
        {
            Assert.True(dut.ContainsKey("2000Horst2000"));
            dut.Add("NEW", new Person(9, "NEWPERSON"));
            Assert.True(dut.ContainsKey("NEW"));
            Assert.Equal(10002, dut.Count);

            dut.Remove("2000Horst2000");
            Assert.Equal(10001, dut.Count);
            Assert.False(dut.ContainsKey("2000Horst2000"));

            Person person = dut.GetValue("NEW", null);

            Assert.Equal("NEWPERSON", person.Name);

            person = dut.GetValue("WTF", new Person(22, "NA"));
            Assert.Equal("NA", person.Name);

            string at100 = dut[100].Item1;

            dut.RemoveAt(100);
            Assert.Equal(10000, dut.Count);
            Assert.Null(dut.GetValue(at100, null));
            Assert.False(dut.ContainsKey(at100));

            dut[500] = Tuple.Create("AT500", new Person(500, "Person500"));
            Assert.True(dut.ContainsKey("AT500"));

            Stopwatch sw = new Stopwatch();

            sw.Start();
            foreach (Tuple <string, Person> dutEntry in dut)
            {
                dut.ContainsKey(dutEntry.Item1);
                dut.GetValue(dutEntry.Item1, null);
            }
            for (int i = 10005; i < 20000; i++)
            {
                dut.Add(i.ToString(), new Person());
            }
            sw.Stop();

            Assert.True(sw.ElapsedMilliseconds < 100);

            dut.Clear();
            Assert.True(dut.Count == 0);
        }