Example #1
0
        public void KeyValuePairDoesNotExist()
        {
            var sut = new BijectiveDictionary <string, int>
            {
                { "FooBar", 0 },
                { "Testing123", 2 }
            };

            Assert.IsFalse(sut.Contains(new KeyValuePair <string, int>("FooBar", 7)));
        }
Example #2
0
        public void CountsAreEqual()
        {
            var sut = new BijectiveDictionary <string, int>
            {
                { "FooBar", 0 },
                { "Testing123", 2 }
            };

            Assert.IsTrue(sut.Count == sut.Inverse.Count);
        }
Example #3
0
        public void BothKeysExist()
        {
            var sut = new BijectiveDictionary <string, int>
            {
                { "FooBar", 0 },
                { "Testing123", 2 }
            };

            Assert.AreEqual("FooBar", sut.Inverse[0]);
            Assert.AreEqual(0, sut["FooBar"]);
        }
Example #4
0
        public void BothBijectionsCleared()
        {
            var sut = new BijectiveDictionary <string, int>
            {
                { "FooBar", 0 },
                { "Testing123", 2 }
            };

            sut.Clear();
            Assert.IsTrue(sut.Count == 0 && sut.Inverse.Count == 0);
        }
Example #5
0
        public void BothKeysRemovedByKeyValuePair()
        {
            var sut = new BijectiveDictionary <string, int>
            {
                { "FooBar", 0 },
                { "Testing123", 2 }
            };

            sut.Remove(new KeyValuePair <string, int>("Testing123", 2));
            Assert.IsFalse(sut.Inverse.ContainsKey(2));
        }
Example #6
0
        public void BothBijectionsSet()
        {
            var sut = new BijectiveDictionary <string, int>
            {
                { "FooBar", 0 },
                { "Testing123", 2 }
            };

            sut["BarFoo"] = 42;

            Assert.AreEqual(42, sut["BarFoo"]);
            Assert.AreEqual("BarFoo", sut.Inverse[42]);
        }
 public BijectiveDictionary()
 {
     this.Reversed          = new BijectiveDictionary <TValue, TKey>(true);
     this.Reversed.Reversed = this;
 }