Beispiel #1
0
 public void SingleRequireSVWithoutOuterTransTest()
 {
     Guid result = Guid.Empty;
     //using (var trans = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(1, 1, 1, 0)))
     //{
     Console.Write("服务执行前的事务属性:");
     //LogTransactionInfo(Transaction.Current);
     var sv = new TransSVAgent();
     result = sv.Required(true);
     Console.Write("服务完成后事务提交前的事务属性:");
     //LogTransactionInfo(Transaction.Current);
     //    trans.Complete();
     //}
     var entity = _repository.GetByID<Category>(result);
     Assert.IsNotNull(entity);
 }
Beispiel #2
0
 public void NotSuppotedFaildSVTest()
 {
     var result = TransInvoke.InvokTransFunction(() =>
     {
         var sv = new TransSVAgent();
         return sv.NotSupported(false);
     }, true, false,
     trans =>
         Assert.AreEqual(trans.TransactionInformation.Status,
         TransactionStatus.Active,
         "不支持事务的服务模式,外部事务与内部事务环境进发生了交互")
     );
 }
Beispiel #3
0
 public void SingleRequireSVDoNotCommitTest()
 {
     var result = TransInvoke.InvokTransFunction(() =>
     {
         var sv = new TransSVAgent();
         return sv.Required(true);
     }, false);
     //using (var trans = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(1, 1, 1, 0)))
     //{
     //    Console.Write("服务执行前的事务属性:");
     //    //LogTransactionInfo(Transaction.Current);
     //    var sv = new TransSVAgent();
     //    result = sv.Required(true);
     //    Console.Write("服务完成后事务提交前的事务属性:");
     //    //LogTransactionInfo(Transaction.Current);
     //}
     var entity = _repository.GetByID<Category>(result);
     Assert.IsNull(entity);
 }
Beispiel #4
0
        public void SingleRequireSVFailedTest()
        {
            var result = TransInvoke.InvokTransFunction(() =>
            {
                var sv = new TransSVAgent();
                return sv.Required(false);
            }, true);

            //using (var trans = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(1, 1, 1, 0)))
            //{
            //    Console.Write("服务执行前的事务属性:");
            //    //LogTransactionInfo(Transaction.Current);
            //    var sv = new TransSVAgent();
            //    result = sv.Required(false);
            //    Console.Write("服务完成后事务提交前的事务属性:");
            //    //LogTransactionInfo(Transaction.Current);
            //}
        }
Beispiel #5
0
        public void RequriesNewWithOutOuterTransTest()
        {
            var sv = new TransSVAgent();
            var result = sv.RequiresNew(true);

            var entity = _repository.GetByID<Category>(result);
            Assert.IsNotNull(entity, "由于外部事务的回滚导致内部事务的回滚");
        }
Beispiel #6
0
        public void RequriesNewSVTest()
        {
            var result = TransInvoke.InvokTransFunction(() =>
            {
                var sv = new TransSVAgent();
                return sv.RequiresNew(true);
            }, true, true,
                trans =>
                    Assert.AreEqual(trans.TransactionInformation.Status,
                    TransactionStatus.Active,
                    "外部事务受到内部事务的影响,无法正确提交")
            );

            var entity = _repository.GetByID<Category>(result);
            Assert.IsNotNull(entity);

            result = TransInvoke.InvokTransFunction(() =>
            {
                var sv = new TransSVAgent();
                return sv.RequiresNew(true);
            }, false, true,
                 trans =>
                        Assert.AreEqual(trans.TransactionInformation.Status,
                        TransactionStatus.Active,
                        "外部事务受到内部事务的影响,无法正确提交"));
            entity = _repository.GetByID<Category>(result);
            Assert.IsNotNull(entity, "由于外部事务的回滚导致内部事务的回滚");
        }
Beispiel #7
0
 public void RequriesNewSVFailedTest()
 {
     var result = TransInvoke.InvokTransFunction(() =>
     {
         var sv = new TransSVAgent();
         return sv.RequiresNew(false);
     }, true, false,
     trans =>
         Assert.AreEqual(trans.TransactionInformation.Status,
         TransactionStatus.Active,
         "外部事务受到内部事务的影响,无法正确提交")
     );
 }
Beispiel #8
0
 public void LoadTest()
 {
     var sv = new TransSVAgent();
     sv.Required(true);
 }
Beispiel #9
0
        public void PreformanceTest()
        {
            CodeTimer.Time("Proxy方式服务批量调用", 1000, () =>
            {
                var proxy = ServiceProxy.CreateProxy<ITransSV>();
                proxy.Supported();
            });

            CodeTimer.Time("Agent方式服务批量调用", 1000, () =>
            {
                var sv = new TransSVAgent();
                sv.Supported(true);
                sv.Close();
            });
            CodeTimer.Time("IIS 承载方式服务批量调用", 1000, () =>
            {
                var client = new TransSVClient();
                client.Supported();
                client.Close();
            }
            );
        }