Ejemplo n.º 1
0
 public void ObjectData()
 {
     aTwoKeysDic2 = new TwoKeysDictionary <object, object, object>();
     Assert.False(aTwoKeysDic2.ContainsKey(new object(), "1"));
     Assert.False(aTwoKeysDic2.ContainsKey(1234567890));
     Assert.False(aTwoKeysDic2.ContainsKey(System.DateTime.Now));
     Assert.False(aTwoKeysDic2.ContainsKey("\""));
     aTwoKeysDic2.Add(1, "2", 3D);
     aTwoKeysDic2.Add("1", 2, 3);
 }
Ejemplo n.º 2
0
        public void Basic()
        {
            aTwoKeysDic = new TwoKeysDictionary <string, string, string>();
            Assert.False(aTwoKeysDic.ContainsKey("INVALID_KEY", "1"));
            Assert.False(aTwoKeysDic.ContainsKey("INVALID_KEY"));
            Assert.False(aTwoKeysDic.ContainsKey(""));
            Assert.False(aTwoKeysDic.ContainsKey("\""));
            Assert.Throws <ArgumentNullException>(() => { aTwoKeysDic.ContainsKey("INVALID_KEY", null); });
            Assert.Throws <ArgumentNullException>(() => { aTwoKeysDic.ContainsKey(null, "INVALID_KEY"); });
            Assert.Throws <ArgumentNullException>(() => { aTwoKeysDic.ContainsKey(null); });

            // Items
            Assert.Throws <KeyNotFoundException>(() => { var obj = aTwoKeysDic.Items("INVALID_KEY"); });
            Assert.Throws <ArgumentNullException>(() => { var obj = aTwoKeysDic.Items(null); });
            Assert.Throws <KeyNotFoundException>(() => { var obj = aTwoKeysDic.Items(""); });

            // Item
            Assert.Throws <KeyNotFoundException>(() => { var str = aTwoKeysDic["INVALID_KEY", "INVALID_KEY"]; });
            Assert.Throws <ArgumentNullException>(() => { var str = aTwoKeysDic["INVALID_KEY", null]; });
            Assert.Throws <ArgumentNullException>(() => { var str = aTwoKeysDic[null, "INVALID_KEY"]; });
            Assert.Throws <ArgumentNullException>(() => { var str = aTwoKeysDic[null, null]; });
            Assert.Throws <KeyNotFoundException>(() => { var str = aTwoKeysDic["INVALID_KEY", ""]; });
            Assert.Throws <KeyNotFoundException>(() => { var str = aTwoKeysDic["", "INVALID_KEY"]; });
            Assert.Throws <KeyNotFoundException>(() => { var str = aTwoKeysDic["", ""]; });

            // Item(値の追加後)
            aTwoKeysDic.Add("KEY1", "KEY2", "VALUE");
            Assert.AreEqual("VALUE", aTwoKeysDic["KEY1", "KEY2"]);
            Assert.Throws <KeyNotFoundException>(() => { var str = aTwoKeysDic["KEY2", "KEY1"]; });
            Assert.Throws <KeyNotFoundException>(() => { var str = aTwoKeysDic["KEY1", "VALUE"]; });
            Assert.Throws <KeyNotFoundException>(() => { var str = aTwoKeysDic["VALUE", "KEY2"]; });
            Assert.Throws <KeyNotFoundException>(() => { var str = aTwoKeysDic["KEY2", "VALUE"]; });
            Assert.Throws <KeyNotFoundException>(() => { var str = aTwoKeysDic["VALUE", "KEY1"]; });
            Assert.Throws <KeyNotFoundException>(() => { var str = aTwoKeysDic["KEY1", "INVALID_KEY"]; });
            Assert.Throws <KeyNotFoundException>(() => { var str = aTwoKeysDic["INVALID_KEY", "KEY2"]; });

            // Add
            Assert.Throws <ArgumentException>(() => { aTwoKeysDic.Add("KEY1", "KEY2", "AnotherValue"); });
            aTwoKeysDic.Add("KEY2", "KEY1", "AnotherValue");
            aTwoKeysDic.Add("key1", "key2", "AnotherValue");
            aTwoKeysDic.Add("key1", "KEY2", "AnotherValue");
            aTwoKeysDic.Add("KEY1", "key2", "AnotherValue");
        }