Esempio n. 1
0
        public void TestIndexer()
        {
            //---------------Set up test pack-------------------
            BOKeyCol col = new BOKeyCol();

            col.Add(new BOKey(new KeyDef("anotherkey")));
            BOKey boKey = new BOKey(new KeyDef("key"));

            col.Add(boKey);
            //---------------Execute Test ----------------------
            IBOKey indexedKey = col["key"];

            //---------------Test Result -----------------------
            Assert.AreSame(boKey, indexedKey);
        }
Esempio n. 2
0
        public void TestIndexerWithNonExistingKey()
        {
            //---------------Set up test pack-------------------
            BOKeyCol col = new BOKeyCol();

            //---------------Execute Test ----------------------
            try
            {
                IBOKey key = col["invalidkey"];
                Assert.Fail("Expected to throw an InvalidKeyException");
            }
            //---------------Test Result -----------------------
            catch (InvalidKeyException ex)
            {
                StringAssert.Contains("does not exist in the collection of keys", ex.Message);
            }
        }
Esempio n. 3
0
        public void TestAddDuplicates()
        {
            //---------------Set up test pack-------------------
            BOKeyCol col   = new BOKeyCol();
            IBOKey   boKey = new BOKey(new KeyDef());

            col.Add(boKey);
            //---------------Execute Test ----------------------
            try
            {
                col.Add(boKey);
                Assert.Fail("Expected to throw an InvalidKeyException");
            }
            //---------------Test Result -----------------------
            catch (InvalidKeyException ex)
            {
                StringAssert.Contains("already exists in the collection", ex.Message);
            }
        }