public void Get_Negative()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems();

            Assert.False(dictionary.TryGetValue(2, out var value));
            Assert.Null(value);
        }
        public void Get_ByKey_ReturnsNull()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems().ToIDictionary();

            Assert.Null(dictionary[2]);
            Assert.Null(dictionary["2"]);
        }
Exemple #3
0
        public void Add()
        {
            var collection = BiDictionaryHelper.CreateEmpty().ToICollection();

            collection.Add(new KeyValuePair <int, string>(0, "1"));

            Assert.Equal("[0, 1]-[1, 0]", collection.GetResult());
        }
Exemple #4
0
        public void Clear()
        {
            var collection = BiDictionaryHelper.CreateWithTwoItems().ToICollection();

            collection.Clear();

            Assert.Empty(collection);
        }
        public void Get_ThrowsKeyNotFoundException_Reverse()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItemsReverse().Reverse;

            var ex = Assert.Throws <KeyNotFoundException>(() => dictionary[2]);

            Assert.Equal("The given key '2' was not present in the dictionary.", ex.Message);
        }
        public void Remove()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems().ToIDictionary();

            dictionary.Remove(0);

            Assert.Equal("[1, 1]-[1, 1]", dictionary.GetResult <int, string>());
        }
        public void Add_ThrowsArgumentException()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems();

            var ex = Assert.Throws <ArgumentException>(() => dictionary.Add(1, "1"));

            Assert.Equal("An item with the same key has already been added. Key: 1", ex.Message);
        }
        public void Add()
        {
            var dictionary = BiDictionaryHelper.CreateEmpty().ToIDictionary();

            dictionary.Add(0, "1");

            Assert.Equal("[0, 1]-[1, 0]", dictionary.GetResult <int, string>());
        }
        public void Get()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems();

            Assert.Equal("0", dictionary[0]);
            Assert.True(dictionary.TryGetValue(0, out var value));
            Assert.Equal("0", value);
        }
Exemple #10
0
        public void Add_Reverse()
        {
            var original   = BiDictionaryHelper.CreateEmptyReverse();
            var collection = original.Reverse.ToICollection();

            collection.Add(new KeyValuePair <int, string>(0, "1"));

            Assert.Equal("[1, 0]-[0, 1]", original.GetResult());
        }
        public void Remove_Negative_Reverse()
        {
            var original   = BiDictionaryHelper.CreateWithTwoItemsReverse();
            var dictionary = original.Reverse.ToIDictionary();

            dictionary.Remove(2);

            Assert.Equal("[0, 0],[1, 1]-[0, 0],[1, 1]", original.GetResult());
        }
Exemple #12
0
        public void Add_ThrowsArgumentException()
        {
            var collection = BiDictionaryHelper.CreateWithTwoItems().ToICollection();

            var ex =
                Assert.Throws <ArgumentException>(() => collection.Add(new KeyValuePair <int, string>(1, "1")));

            Assert.Equal("An item with the same key has already been added. Key: 1", ex.Message);
        }
        public void Set()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems().ToIDictionary();

            dictionary[0] = "0";
            dictionary[1] = "2";

            Assert.Equal("[0, 0],[1, 2]-[0, 0],[1, 1],[2, 1]", dictionary.GetResult <int, string>());
        }
        public void Set()
        {
            var dictionary = BiDictionaryHelper.CreateEmpty();

            dictionary[0] = "0";
            dictionary[1] = "2";

            Assert.Equal("[0, 0],[1, 2]-[0, 0],[2, 1]", dictionary.GetResult());
        }
        public void Add_Negative()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems();

            var notAdded = dictionary.TryAdd(1, "1");

            Assert.False(notAdded);
            Assert.Equal("[0, 0],[1, 1]-[0, 0],[1, 1]", dictionary.GetResult());
        }
        public void Add_Reverse()
        {
            var original   = BiDictionaryHelper.CreateEmptyReverse();
            var dictionary = original.Reverse.ToIDictionary();

            dictionary.Add(0, "1");

            Assert.Equal("[1, 0]-[0, 1]", original.GetResult());
        }
        public void Add()
        {
            var dictionary = BiDictionaryHelper.CreateEmpty();

            dictionary.Add(0, "0");
            var added = dictionary.TryAdd(1, "1");

            Assert.True(added);
            Assert.Equal("[0, 0],[1, 1]-[0, 0],[1, 1]", dictionary.GetResult());
        }
        public void Add_Negative_Reverse()
        {
            var original   = BiDictionaryHelper.CreateWithTwoItemsReverse();
            var dictionary = original.Reverse;

            var notAdded = dictionary.TryAdd(1, "1");

            Assert.False(notAdded);
            Assert.Equal("[0, 0],[1, 1]-[0, 0],[1, 1]", original.GetResult());
        }
Exemple #19
0
        public void Remove_Negative()
        {
            var collection = BiDictionaryHelper.CreateWithTwoItems().ToICollection();

            var item = new KeyValuePair <int, string>(2, "2");
            var wasNotRemovedFromCollection = collection.Remove(item);

            Assert.False(wasNotRemovedFromCollection);
            Assert.Equal("[0, 0],[1, 1]-[0, 0],[1, 1]", collection.GetResult());
        }
        public void Clear_Reverse()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItemsReverse().Reverse.ToIDictionary();

            dictionary.Clear();

            Assert.Empty(dictionary);
            Assert.Empty(dictionary.Values);
            Assert.Empty(dictionary.Keys);
        }
        public void Clear()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems();

            dictionary.Clear();

            Assert.Empty(dictionary);
            Assert.Empty(dictionary.Values);
            Assert.Empty(dictionary.Keys);
        }
        public void Enumerate()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems();

            var sb = new StringBuilder();

            sb.AppendJoin(",", dictionary);

            Assert.Equal("[0, 0],[1, 1]", sb.ToString());
        }
        public void Set_Reverse()
        {
            var original   = BiDictionaryHelper.CreateWithTwoItemsReverse();
            var dictionary = original.Reverse;

            dictionary[0] = "0";
            dictionary[1] = "2";

            Assert.Equal("[0, 0],[2, 1]-[0, 0],[1, 2]", original.GetResult());
        }
Exemple #24
0
        public void Enumerate_Reverse()
        {
            var collection = BiDictionaryHelper.CreateWithTwoItemsReverse().Reverse.ToICollection();

            var sb = new StringBuilder();

            sb.AppendJoin(",", collection);

            Assert.Equal("[0, 0],[1, 1]", sb.ToString());
        }
Exemple #25
0
        public void Remove()
        {
            var collection = BiDictionaryHelper.CreateWithTwoItems().ToICollection();

            var item = collection.ElementAt(0);
            var wasRemovedFromCollection = collection.Remove(item);

            Assert.True(wasRemovedFromCollection);
            Assert.Equal("[1, 1]-[0, 0],[1, 1]", collection.GetResult());
        }
Exemple #26
0
        public void Remove_Reverse()
        {
            var original   = BiDictionaryHelper.CreateWithTwoItemsReverse();
            var collection = original.Reverse.ToICollection();

            var item = collection.ElementAt(0);
            var wasRemovedFromCollection = collection.Remove(item);

            Assert.True(wasRemovedFromCollection);
            Assert.Equal("[0, 0],[1, 1]-[1, 1]", original.GetResult());
        }
        public void Add_Reverse()
        {
            var original   = BiDictionaryHelper.CreateEmptyReverse();
            var dictionary = original.Reverse;

            dictionary.Add(0, "0");
            var added = dictionary.TryAdd(1, "1");

            Assert.True(added);
            Assert.Equal("[0, 0],[1, 1]-[0, 0],[1, 1]", original.GetResult());
        }
        public void Remove()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems();

            var wasRemoved0 = dictionary.Remove(0);
            var wasRemoved1 = dictionary.Remove(1, out var removedValue);

            Assert.True(wasRemoved0);
            Assert.True(wasRemoved1);
            Assert.Equal("1", removedValue);
            Assert.Equal("-", dictionary.GetResult());
        }
        public void Remove_Negative()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems();

            var wasNotRemoved0 = dictionary.Remove(2);
            var wasNotRemoved1 = dictionary.Remove(2, out var notRemovedValue);

            Assert.False(wasNotRemoved0);
            Assert.False(wasNotRemoved1);
            Assert.Null(notRemovedValue);
            Assert.Equal("[0, 0],[1, 1]-[0, 0],[1, 1]", dictionary.GetResult());
        }
        public void Enumerate()
        {
            var dictionary = BiDictionaryHelper.CreateWithTwoItems().ToIDictionary().ToIEnumerable();

            var sb = new StringBuilder();

            foreach (KeyValuePair <int, string> item in dictionary)
            {
                sb.Append(item);
            }

            Assert.Equal("[0, 0][1, 1]", sb.ToString());
        }