Exemplo n.º 1
0
 public void Simple()
 {
     var target = new AutoKeyDictionary<string, int>(x => x.ToString()) { 2 };
     Assert.IsTrue(target.ContainsKey("2"));
     Assert.IsTrue(target.InternalRemove("2"));
     Assert.IsFalse(target.ContainsKey("2"));
 }
Exemplo n.º 2
0
 public void Interface()
 {
     var target = new AutoKeyDictionary<string, int>(x => x.ToString());
     ICollection<int> collection = target;
     collection.Add(1);
     Assert.IsTrue(target.Contains(1));
 }
Exemplo n.º 3
0
 public void Simple()
 {
     var target = new AutoKeyDictionary<string, int>(x => x.ToString()) { 3 };
     ICollection<int> collection = target;
     Assert.IsTrue(collection.Remove(3));
     Assert.IsFalse(target.ContainsKey("3"));
     Assert.IsFalse(collection.Remove(3));
 }
Exemplo n.º 4
0
        public void Interface()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString());
            ICollection <int> collection = target;

            collection.Add(1);
            Assert.IsTrue(target.Contains(1));
        }
Exemplo n.º 5
0
 public void IndexerTestKeyExist()
 {
     var sut = new AutoKeyDictionary<int, string>(i => i + 1, i => i < 3);
     var value = "Pepito";
     sut.Add(2, value);
     var result = sut[1];
     Assert.Equal(value, result);
 }
Exemplo n.º 6
0
 public void ContainsTest()
 {
     var target = new AutoKeyDictionary<string, int>(x => x.ToString()) { 2 };
     ICollection<int> collection = target;
     Assert.IsTrue(collection.Contains(2));
     Assert.IsFalse(collection.Contains(1));
     Assert.IsFalse(collection.Contains(3));
 }
Exemplo n.º 7
0
 public void TryGetTestKeyExist()
 {
     var sut = new AutoKeyDictionary<int, string>(i => i + 1, i => i < 3);
     var expected = "Pepito";
     sut.Add(2, expected);
     string actual;
     var result = sut.TryGetValue(1, out actual);
     Assert.Equal(expected, actual);
 }
Exemplo n.º 8
0
 public void Simple()
 {
     var target = new AutoKeyDictionary<string, int>(x => x.ToString()) { 1, 2, 3 };
     ICollection<int> collection = target;
     var pairs = new int[3];
     collection.CopyTo(pairs, 0);
     Assert.AreEqual(1, pairs[0]);
     Assert.AreEqual(2, pairs[1]);
     Assert.AreEqual(3, pairs[2]);
 }
Exemplo n.º 9
0
        public void NonExisting()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString())
            {
                1
            };
            ICollection <int> collection = target;

            Assert.IsFalse(collection.Remove(2));
        }
Exemplo n.º 10
0
        public void IndexerTestKeyExist()
        {
            var sut   = new AutoKeyDictionary <int, string>(i => i + 1, i => i < 3);
            var value = "Pepito";

            sut.Add(2, value);
            var result = sut[1];

            Assert.Equal(value, result);
        }
Exemplo n.º 11
0
        public void TryGetTestKeyExist()
        {
            var sut      = new AutoKeyDictionary <int, string>(i => i + 1, i => i < 3);
            var expected = "Pepito";

            sut.Add(2, expected);
            string actual;
            var    result = sut.TryGetValue(1, out actual);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 12
0
        public void Simple()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString())
            {
                2
            };

            Assert.IsTrue(target.ContainsKey("2"));
            Assert.IsFalse(target.ContainsKey("1"));
            Assert.IsFalse(target.ContainsKey("3"));
        }
Exemplo n.º 13
0
        public void Simple()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString())
            {
                3
            };
            ICollection <int> collection = target;

            Assert.IsTrue(collection.Remove(3));
            Assert.IsFalse(target.ContainsKey("3"));
            Assert.IsFalse(collection.Remove(3));
        }
Exemplo n.º 14
0
        public void ContainsTest()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString())
            {
                2
            };
            ICollection <int> collection = target;

            Assert.IsTrue(collection.Contains(2));
            Assert.IsFalse(collection.Contains(1));
            Assert.IsFalse(collection.Contains(3));
        }
Exemplo n.º 15
0
        private AutoKeyDictionary<Type, object> GetDictionary(string name)
        {
            AutoKeyDictionary<Type, object> dic;
            var hadValue = lookupDictionaries.TryGetValue(name, out dic);
            if (hadValue)
            {
                return dic;
            }

            var autoKeyDictionary = new AutoKeyDictionary<Type, object>(t => t.GetTypeInfo().BaseType, t => t != null);
            lookupDictionaries.Add(name, autoKeyDictionary);
            return autoKeyDictionary;
        }
Exemplo n.º 16
0
        public void Simple()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString())
            {
                1, 2, 3
            };
            ICollection <int> collection = target;
            var pairs = new int[3];

            collection.CopyTo(pairs, 0);
            Assert.AreEqual(1, pairs[0]);
            Assert.AreEqual(2, pairs[1]);
            Assert.AreEqual(3, pairs[2]);
        }
Exemplo n.º 17
0
        private AutoKeyDictionary <Type, object> GetDictionary(string name)
        {
            AutoKeyDictionary <Type, object> dic;
            var hadValue = lookupDictionaries.TryGetValue(name, out dic);

            if (hadValue)
            {
                return(dic);
            }

            var autoKeyDictionary = new AutoKeyDictionary <Type, object>(t => t.GetTypeInfo().BaseType, t => t != null);

            lookupDictionaries.Add(name, autoKeyDictionary);
            return(autoKeyDictionary);
        }
Exemplo n.º 18
0
        public void Simple()
        {
            var target = new AutoKeyDictionary<string, int>(x => x.ToString()) { 2, 4, 9 };
            IEnumerable<int> enumerable = target;
            var enumerator = enumerable.GetEnumerator();

            enumerator.MoveNext();
            var current = enumerator.Current;
            Assert.AreEqual(2, current);

            enumerator.MoveNext();
            current = enumerator.Current;
            Assert.AreEqual(4, current);

            enumerator.MoveNext();
            current = enumerator.Current;
            Assert.AreEqual(9, current);
        }
Exemplo n.º 19
0
        public void Simple()
        {
            var target = new AutoKeyDictionary<string, int>(x => x.ToString()) { 2, 4, 9 };
            var keys = target.Keys;

            IEnumerable<string> enumerable = keys;
            var enumerator = enumerable.GetEnumerator();

            enumerator.MoveNext();
            var current = enumerator.Current;
            Assert.AreEqual("2", current);

            enumerator.MoveNext();
            current = enumerator.Current;
            Assert.AreEqual("4", current);

            enumerator.MoveNext();
            current = enumerator.Current;
            Assert.AreEqual("9", current);
        }
Exemplo n.º 20
0
        public void Interface()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString())
            {
                2, 4, 9
            };
            IEnumerable enumerable = target;
            var         enumerator = enumerable.GetEnumerator();

            enumerator.MoveNext();
            var current = (int)enumerator.Current;

            Assert.AreEqual(2, current);

            enumerator.MoveNext();
            current = (int)enumerator.Current;
            Assert.AreEqual(4, current);

            enumerator.MoveNext();
            current = (int)enumerator.Current;
            Assert.AreEqual(9, current);
        }
Exemplo n.º 21
0
        public void Simple()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString())
            {
                2, 4, 9
            };
            var valueCollection = target.Values;

            IEnumerable <int> enumerable = valueCollection;
            var enumerator = enumerable.GetEnumerator();

            enumerator.MoveNext();
            var current = enumerator.Current;

            Assert.AreEqual(2, current);

            enumerator.MoveNext();
            current = enumerator.Current;
            Assert.AreEqual(4, current);

            enumerator.MoveNext();
            current = enumerator.Current;
            Assert.AreEqual(9, current);
        }
Exemplo n.º 22
0
        public void Simple()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString())
            {
                2, 4, 9
            };
            var keys = target.Keys;

            IEnumerable <string> enumerable = keys;
            var enumerator = enumerable.GetEnumerator();

            enumerator.MoveNext();
            var current = enumerator.Current;

            Assert.AreEqual("2", current);

            enumerator.MoveNext();
            current = enumerator.Current;
            Assert.AreEqual("4", current);

            enumerator.MoveNext();
            current = enumerator.Current;
            Assert.AreEqual("9", current);
        }
Exemplo n.º 23
0
 public void NonExisting()
 {
     var target = new AutoKeyDictionary<string, int>(x => x.ToString()) { 1 };
     ICollection<int> collection = target;
     Assert.IsFalse(collection.Remove(2));
 }
Exemplo n.º 24
0
        public void CapacityComparer()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString(), StringComparer.InvariantCultureIgnoreCase, 1);

            Assert.AreEqual(StringComparer.InvariantCultureIgnoreCase, target.Comparer);
        }
Exemplo n.º 25
0
 public void IndexerTestKeyDoesNotExist()
 {
     var sut = new AutoKeyDictionary<int?, string>(i => i + 1, i => i < 2);
     var result = sut[1];
 }
Exemplo n.º 26
0
 public void TEST()
 {
     AutoKeyDictionary <TestClass> dictionary = new AutoKeyDictionary <TestClass>("Id", "Name");
 }
Exemplo n.º 27
0
        public void ExceptionNullKey()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString());

            Assert.Throws <ArgumentNullException>(() => target.InternalRemove(null));
        }
Exemplo n.º 28
0
 public void ExceptionNullKey()
 {
     var target = new AutoKeyDictionary<string, int>(x => x.ToString());
     target.InternalRemove(null);
 }
Exemplo n.º 29
0
 public void IndexerTestKeyDoesNotExist()
 {
     var sut = new AutoKeyDictionary<int?, string>(i => i + 1, i => i < 2);
     Assert.Throws<KeyNotFoundException>(() => sut[1]);
 }
Exemplo n.º 30
0
 public void IndexerTestKeyDoesNotExist()
 {
     var sut    = new AutoKeyDictionary <int?, string>(i => i + 1, i => i < 2);
     var result = sut[1];
 }
Exemplo n.º 31
0
        public void IndexerTestKeyDoesNotExist()
        {
            var sut = new AutoKeyDictionary <int?, string>(i => i + 1, i => i < 2);

            Assert.Throws <KeyNotFoundException>(() => sut[1]);
        }
Exemplo n.º 32
0
        public void ExceptionNullKey()
        {
            var target = new AutoKeyDictionary <string, int>(x => x.ToString());

            target.InternalRemove(null);
        }
Exemplo n.º 33
0
 public void CapacityComparer()
 {
     var target = new AutoKeyDictionary<string, int>(x => x.ToString(), StringComparer.InvariantCultureIgnoreCase, 1);
     Assert.AreEqual(StringComparer.InvariantCultureIgnoreCase, target.Comparer);
 }