private IRepositoryInterface CreateProxy(RepositoryInterfaceImpl target)
        {
            MapPersistenceExceptionTranslator mpet = new MapPersistenceExceptionTranslator();

            mpet.AddTranslation(persistenceException, new InvalidDataAccessApiUsageException("", persistenceException));
            ProxyFactory pf = new ProxyFactory(target);

            pf.AddInterface(typeof(IRepositoryInterface));
            AddPersistenceExceptionTranslation(pf, mpet);
            return((IRepositoryInterface)pf.GetProxy());
        }
        public void NoTranslationNeeded()
        {
            RepositoryInterfaceImpl target = new RepositoryInterfaceImpl();
            IRepositoryInterface    ri     = CreateProxy(target);

            ri.Throws();

            target.Behavior = persistenceException;

            try
            {
                ri.Throws();
                Assert.Fail();
            } catch (Exception ex)
            {
                Assert.AreSame(persistenceException, ex);
            }
        }
        private void DoTestTranslationNeededForTheseExceptions(RepositoryInterfaceImpl target)
        {
            IRepositoryInterface ri = CreateProxy(target);

            target.Behavior = persistenceException;
            try
            {
                ri.Throws();
                Assert.Fail();
            } catch (DataAccessException ex)
            {
                //Expected
                Assert.AreSame(persistenceException, ex.InnerException);
            } catch (PersistenceException)
            {
                Assert.Fail("Should have been translated");
            }
        }
        public void NoTranslationNeeded()
        {
            RepositoryInterfaceImpl target = new RepositoryInterfaceImpl();
            IRepositoryInterface ri = CreateProxy(target);

            ri.Throws();

            target.Behavior = persistenceException;

            try
            {
                ri.Throws();
                Assert.Fail();
            } catch (Exception ex)
            {
                Assert.AreSame(persistenceException, ex);
            }
        }
 private IRepositoryInterface CreateProxy(RepositoryInterfaceImpl target)
 {
     MapPersistenceExceptionTranslator mpet = new MapPersistenceExceptionTranslator();
     mpet.AddTranslation(persistenceException, new InvalidDataAccessApiUsageException("", persistenceException));
     ProxyFactory pf = new ProxyFactory(target);
     pf.AddInterface(typeof(IRepositoryInterface));
     AddPersistenceExceptionTranslation(pf, mpet);
     return (IRepositoryInterface) pf.GetProxy();
 }
 private void DoTestTranslationNeededForTheseExceptions(RepositoryInterfaceImpl target)
 {
     IRepositoryInterface ri = CreateProxy(target);
     target.Behavior = persistenceException;
     try
     {
         ri.Throws();
         Assert.Fail();
     } catch (DataAccessException ex)
     {
         //Expected
         Assert.AreSame(persistenceException, ex.InnerException);
     } catch (PersistenceException)
     {
         Assert.Fail("Should have been translated");
     }
 }