示例#1
0
        public void TestRemovalException()
        {
            pool.size = 4;
            pool.Add(new ClassToBeInjected());
            TestDelegate testDelegate = delegate()
            {
                pool.Remove(new InjectableDerivedClass());
            };
            PoolException ex = Assert.Throws <PoolException> (testDelegate);

            Assert.AreEqual(PoolExceptionType.TYPE_MISMATCH, ex.type);
        }
        public void TestRemovalException()
        {
            binding.Size = 4;
            b.To(new ClassToBeInjected());
            TestDelegate testDelegate = delegate()
            {
                b.RemoveValue(new InjectableDerivedClass());
            };
            PoolException ex = Assert.Throws <PoolException> (testDelegate);

            Assert.That(ex.type == PoolExceptionType.TYPE_MISMATCH);
        }
示例#3
0
        public void TestPoolOverflowException()
        {
            pool.size = 4;
            for (int a = 0; a < pool.size; a++)
            {
                pool.Add(new ClassToBeInjected());
            }

            for (int a = pool.size; a > 0; a--)
            {
                Assert.AreEqual(a, pool.available);
                pool.GetInstance();
            }

            TestDelegate testDelegate = delegate()
            {
                pool.GetInstance();
            };
            PoolException ex = Assert.Throws <PoolException> (testDelegate);

            Assert.AreEqual(PoolExceptionType.OVERFLOW, ex.type);
        }
        public void TestPoolOverflowException()
        {
            binding.Size = 4;
            for (int a = 0; a < binding.Size; a++)
            {
                b.To(new ClassToBeInjected());
            }

            for (int a = binding.Size; a > 0; a--)
            {
                Assert.AreEqual(a, binding.Available);
                binding.GetInstance();
            }

            TestDelegate testDelegate = delegate()
            {
                binding.GetInstance();
            };
            PoolException ex = Assert.Throws <PoolException> (testDelegate);

            Assert.That(ex.type == PoolExceptionType.OVERFLOW);
        }
        private void assertThrowsFailedFacade(TestDelegate testDelegate)
        {
            PoolException ex1 = Assert.Throws <PoolException>(testDelegate);

            Assert.That(ex1.type == PoolExceptionType.FAILED_FACADE);
        }