• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Objects.TestObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Spring.Objects.TestObject的典型用法代码示例。如果您正苦于以下问题:C# TestObject类的具体用法?C# TestObject怎么用?C# TestObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TestObject类属于Spring.Objects命名空间,在下文中一共展示了TestObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CannotCommitTransaction

        public void CannotCommitTransaction()
        {
            ITransactionAttribute txatt = new DefaultTransactionAttribute();
            MethodInfo m = typeof (ITestObject).GetMethod("GetDescription");
            MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource();
            tas.AddTransactionalMethod(m, txatt);


            IPlatformTransactionManager ptm = PlatformTxManagerForNewTransaction();

            ITransactionStatus status = TransactionStatusForNewTransaction();
            Expect.On(ptm).Call(ptm.GetTransaction(txatt)).Return(status);
            UnexpectedRollbackException ex = new UnexpectedRollbackException("foobar", null);
            ptm.Commit(status);
            LastCall.On(ptm).Throw(ex);
            mocks.ReplayAll();

            TestObject to = new TestObject();
            ITestObject ito = (ITestObject) Advised(to, ptm, tas);

            try
            {
                ito.GetDescription();
                Assert.Fail("Shouldn't have succeeded");
            } catch (UnexpectedRollbackException thrown)
            {
                Assert.IsTrue(thrown == ex);
            }

            mocks.VerifyAll();


            
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:34,代码来源:AbstractTransactionAspectTests.cs


示例2: WithNonSerializableObject

		public void WithNonSerializableObject()
		{
			TestObject o = new TestObject();
			Assert.IsFalse(o is ISerializable);
			Assert.IsFalse(IsSerializable(o));
            Assert.Throws<SerializationException>(() => TrySerialization(o));
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:7,代码来源:SerializationTestUtils.cs


示例3: CoordinatorDeclarativeWithAttributes

        public void CoordinatorDeclarativeWithAttributes()
        {
            ITestCoord coord = ctx["testCoordinator"] as ITestCoord;
            Assert.IsNotNull(coord);
            CallCountingTransactionManager ccm = ctx["transactionManager"] as CallCountingTransactionManager;
            Assert.IsNotNull(ccm);
            LoggingAroundAdvice advice = (LoggingAroundAdvice)ctx["consoleLoggingAroundAdvice"];
            Assert.IsNotNull(advice);

            ITestObjectMgr testObjectMgr = ctx["testObjectManager"] as ITestObjectMgr;
            Assert.IsNotNull(testObjectMgr);
            //Proxied due to NameMatchMethodPointcutAdvisor
            Assert.IsTrue(AopUtils.IsAopProxy(coord));

            //Proxied due to DefaultAdvisorAutoProxyCreator
            Assert.IsTrue(AopUtils.IsAopProxy(testObjectMgr));


            TestObject to1 = new TestObject("Jack", 7);
            TestObject to2 = new TestObject("Jill", 6);

            Assert.AreEqual(0, ccm.begun);
            Assert.AreEqual(0, ccm.commits);
            Assert.AreEqual(0, advice.numInvoked);
            
            coord.WorkOn(to1,to2);
            
            Assert.AreEqual(1, ccm.begun);
            Assert.AreEqual(1, ccm.commits);
            Assert.AreEqual(1, advice.numInvoked);
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:31,代码来源:AutoDeclarativeTxTests.cs


示例4: WithNonSerializableObject

		public void WithNonSerializableObject()
		{
			TestObject o = new TestObject();
			Assert.IsFalse(o is ISerializable);
			Assert.IsFalse(IsSerializable(o));
			TrySerialization(o);
		}
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:7,代码来源:SerializationTestUtils.cs


示例5: PerformOperations

        public static void PerformOperations(ITestObjectManager mgr,
            ITestObjectDao dao)
        {
            Assert.IsNotNull(mgr);
            TestObject to1 = new TestObject();
            to1.Name = "Jack";
            to1.Age = 7;
            TestObject to2 = new TestObject();
            to2.Name = "Jill";
            to2.Age = 8;
            mgr.SaveTwoTestObjects(to1, to2);

            TestObject to = dao.FindByName("Jack");
            Assert.IsNotNull(to);

            to = dao.FindByName("Jill");
            Assert.IsNotNull(to);
            Assert.AreEqual("Jill", to.Name);

            mgr.DeleteTwoTestObjects("Jack", "Jill");

            to = dao.FindByName("Jack");
            Assert.IsNull(to);

            to = dao.FindByName("Jill");
            Assert.IsNull(to);
        }
开发者ID:smnbss,项目名称:spring-net,代码行数:27,代码来源:TransactionTemplateTests.cs


示例6: AddAndRemoveEventHandlerThroughIntroduction

 public void AddAndRemoveEventHandlerThroughIntroduction()
 {
     TestObject target = new TestObject();
     DoubleClickableIntroduction dci = new DoubleClickableIntroduction();
     DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(dci);
     CountingBeforeAdvice countingBeforeAdvice = new CountingBeforeAdvice();
     target.Name = "SOME-NAME";
     ProxyFactory pf = new ProxyFactory(target);
     pf.AddIntroduction(advisor);
     pf.AddAdvisor(new DefaultPointcutAdvisor(countingBeforeAdvice));
     object proxy = pf.GetProxy();
     ITestObject to = proxy as ITestObject;
     Assert.IsNotNull(to);
     Assert.AreEqual("SOME-NAME", to.Name);
     IDoubleClickable doubleClickable = proxy as IDoubleClickable;
     // add event handler through introduction
     doubleClickable.DoubleClick += new EventHandler(OnClick);
     OnClickWasCalled = false;
     doubleClickable.FireDoubleClickEvent();
     Assert.IsTrue(OnClickWasCalled);
     Assert.AreEqual(3, countingBeforeAdvice.GetCalls());
     // remove event handler through introduction
     doubleClickable.DoubleClick -= new EventHandler(OnClick);
     OnClickWasCalled = false;
     doubleClickable.FireDoubleClickEvent();
     Assert.IsFalse(OnClickWasCalled);
     Assert.AreEqual(5, countingBeforeAdvice.GetCalls());
 }
开发者ID:spring-projects,项目名称:spring-net,代码行数:28,代码来源:ProxyFactoryTests.cs


示例7: MapRow

	    protected override object MapRow(IDataReader reader, int num)
	    {
            TestObject to = new TestObject();
            to.ObjectNumber = reader.GetInt32(0);
            to.Age = reader.GetInt32(1);
            to.Name = reader.GetString(2);
	        return to;
	    }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:8,代码来源:TestObjectQuery.cs


示例8: Update

 public void Update(TestObject to)
 {
     AdoTemplate.ExecuteNonQuery(CommandType.Text,
         String.Format("UPDATE TestObjects SET Age={0}, Name='{1}' where TestObjectNo = {2}",
         to.Age,
         to.Name,
         to.ObjectNumber));
 }
开发者ID:spring-projects,项目名称:spring-net,代码行数:8,代码来源:TestObjectDao.cs


示例9: ApplyResources

 public void ApplyResources()
 {
     TestObject value = new TestObject();
     StaticMessageSource msgSource = new StaticMessageSource();
     msgSource.ApplyResources(value, "testObject", CultureInfo.InvariantCulture);
     Assert.AreEqual("Mark", value.Name, "Name property value not applied.");
     Assert.AreEqual(35, value.Age, "Age property value not applied.");
 }
开发者ID:spring-projects,项目名称:spring-net,代码行数:8,代码来源:StaticMessageSourceTests.cs


示例10: SaveTwoTestObjects

 public void SaveTwoTestObjects(TestObject to1, TestObject to2)
 {
     LOG.Debug("TransactionActive = " + TransactionSynchronizationManager.ActualTransactionActive);
     //Console.WriteLine("TransactionSynchronizationManager.CurrentTransactionIsolationLevel = " +
     //                  TransactionSynchronizationManager.CurrentTransactionIsolationLevel);
     //Console.WriteLine("System.Transactions.Transaction.Current.IsolationLevel = " + System.Transactions.Transaction.Current.IsolationLevel);
     testObjectDao.Create(to1.Name, to1.Age);
     testObjectDao.Create(to2.Name, to2.Age);
 }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:9,代码来源:TestObjectManager.cs


示例11: ApplyResources

        public void ApplyResources()
        {
            //Add another resource manager to the list
            TestObject to = new TestObject();
            ComponentResourceManager mgr = new ComponentResourceManager(to.GetType());
            resourceManagerList.Add(mgr);
            messageSource.ResourceManagers = resourceManagerList;

            messageSource.ApplyResources(to, "testObject", CultureInfo.CurrentCulture);
            Assert.AreEqual("Mark", to.Name);
            Assert.AreEqual(35, to.Age);
        }
开发者ID:smnbss,项目名称:spring-net,代码行数:12,代码来源:ResourceSetMessageSourceTests.cs


示例12: ExtractData

 public object ExtractData(IDataReader reader)
 {
     IList testObjects = new ArrayList();
     while (reader.Read())
     {
         TestObject to = new TestObject();
         //object foo = reader.GetDataTypeName(0);
         to.ObjectNumber = (int) reader.GetInt64(0);
         to.Name = reader.GetString(1);
         testObjects.Add(to);
     }
     return testObjects;
 }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:13,代码来源:OracleAdoTemplateTests.cs


示例13: ProxyIsJustInterface

        public void ProxyIsJustInterface()
        {
            TestObject target = new TestObject();
            target.Age = 32;

            AdvisedSupport advised = new AdvisedSupport();
            advised.Target = target;
            advised.Interfaces = new Type[] { typeof(ITestObject) };

            object proxy = CreateProxy(advised);

            Assert.IsTrue(proxy is ITestObject);
            Assert.IsFalse(proxy is TestObject);
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:14,代码来源:CompositionAopProxyTests.cs


示例14: TestIntroductionInterceptorWithDelegation

		public void TestIntroductionInterceptorWithDelegation()
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ITimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);
	
			ITimeStampedIntroduction ts = MockRepository.GenerateMock<ITimeStampedIntroduction>();
			ts.Stub(x => x.TimeStamp).Return(EXPECTED_TIMESTAMP);

			DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);
			factory.AddIntroduction(advisor);

			ITimeStamped tsp = (ITimeStamped) factory.GetProxy();
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);
		}
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:15,代码来源:DelegatingIntroductionInterceptorTests.cs


示例15: TestIntroductionInterceptorWithInterfaceHierarchy

		public void TestIntroductionInterceptorWithInterfaceHierarchy() 
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ISubTimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);

            ISubTimeStampedIntroduction ts = MockRepository.GenerateMock<ISubTimeStampedIntroduction>();
			ts.Stub(x => x.TimeStamp).Return(EXPECTED_TIMESTAMP);

			DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);
			// we must add introduction, not an advisor
			factory.AddIntroduction(advisor);

			object proxy = factory.GetProxy();
			ISubTimeStamped tsp = (ISubTimeStamped) proxy;
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);
		}
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:17,代码来源:DelegatingIntroductionInterceptorTests.cs


示例16: testIntroductionInterceptorWithDelegation

		public void testIntroductionInterceptorWithDelegation()
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ITimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);
	
			IDynamicMock tsControl = new DynamicMock(typeof(ITimeStampedIntroduction));
			ITimeStampedIntroduction ts = (ITimeStampedIntroduction) tsControl.Object;
			tsControl.ExpectAndReturn("TimeStamp", EXPECTED_TIMESTAMP);

			DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);
			factory.AddIntroduction(advisor);

			ITimeStamped tsp = (ITimeStamped) factory.GetProxy();
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);
	
			tsControl.Verify();
		}
开发者ID:fuadm,项目名称:spring-net,代码行数:18,代码来源:DelegatingIntroductionInterceptorTests.cs


示例17: testIntroductionInterceptorWithInterfaceHierarchy

		public void testIntroductionInterceptorWithInterfaceHierarchy() 
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ISubTimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);

			IDynamicMock tsControl = new DynamicMock(typeof(ISubTimeStampedIntroduction));
			ISubTimeStampedIntroduction ts = (ISubTimeStampedIntroduction) tsControl.Object;
			tsControl.ExpectAndReturn("TimeStamp", EXPECTED_TIMESTAMP);

			DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);
			// we must add introduction, not an advisor
			factory.AddIntroduction(advisor);

			object proxy = factory.GetProxy();
			ISubTimeStamped tsp = (ISubTimeStamped) proxy;
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);

			tsControl.Verify();
		}
开发者ID:fuadm,项目名称:spring-net,代码行数:20,代码来源:DelegatingIntroductionInterceptorTests.cs


示例18: IndexedTestObject

		public IndexedTestObject()
		{
			TestObject to0 = new TestObject("name0", 0);
			TestObject to1 = new TestObject("name1", 0);
			TestObject to2 = new TestObject("name2", 0);
			TestObject to3 = new TestObject("name3", 0);
			TestObject to4 = new TestObject("name4", 0);
			TestObject to5 = new TestObject("name5", 0);
			TestObject to6 = new TestObject("name6", 0);
			TestObject to7 = new TestObject("name7", 0);
			array = new TestObject[] {to0, to1};
			list = new ArrayList();
			list.Add(to2);
			list.Add(to3);
			set = new HashedSet();
			set.Add(to6);
			set.Add(to7);
			map = new Hashtable();
			map["key1"] = to4;
			map["key2"] = to5;
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:21,代码来源:IndexedTestObject.cs


示例19: TestIntroductionInterceptorWithSuperInterface

		public void TestIntroductionInterceptorWithSuperInterface()  
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ITimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);

            ISubTimeStamped ts = MockRepository.GenerateMock<ISubTimeStampedIntroduction>();
			ts.Stub(x => x.TimeStamp).Return(EXPECTED_TIMESTAMP);

			factory.AddIntroduction(0, new DefaultIntroductionAdvisor(
				(ISubTimeStampedIntroduction)ts,
				typeof(ITimeStamped))
				);

			ITimeStamped tsp = (ITimeStamped) factory.GetProxy();
			Assert.IsTrue(!(tsp is ISubTimeStamped));
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);
		}
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:18,代码来源:DelegatingIntroductionInterceptorTests.cs


示例20: DoTestRollbackOnException

        private void DoTestRollbackOnException(Exception exception, bool shouldRollback, bool rollbackException)
        {
            ITransactionAttribute txatt = new ConfigurableTransactionAttribute(shouldRollback);


            MethodInfo mi = typeof (ITestObject).GetMethod("Exceptional");

            MethodMapTransactionAttributeSource tas = new MethodMapTransactionAttributeSource();
            tas.AddTransactionalMethod(mi, txatt);
            ITransactionStatus status = TransactionStatusForNewTransaction();

            IPlatformTransactionManager ptm =
                (IPlatformTransactionManager) mocks.DynamicMock(typeof (IPlatformTransactionManager));

            
            Expect.On(ptm).Call(ptm.GetTransaction(txatt)).Return(status);
            

            if (shouldRollback)
            {
                ptm.Rollback(status);
            }
            else
            {
                ptm.Commit(status);
            }
            TransactionSystemException tex = new TransactionSystemException("system exception");
            if (rollbackException)
            {
                LastCall.On(ptm).Throw(tex).Repeat.Once();
            }
            else
            {
                LastCall.On(ptm).Repeat.Once();
            }
            mocks.ReplayAll();

            TestObject to = new TestObject();
            ITestObject ito = (ITestObject) Advised(to, ptm, tas);

            try
            {
                ito.Exceptional(exception);
                Assert.Fail("Should have thrown exception");
            } catch (Exception e)
            {
                if (rollbackException)
                {
                    Assert.AreEqual(tex, e);
                }
                else
                {
                    Assert.AreEqual(exception, e);
                }
            }

            mocks.VerifyAll();

        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:59,代码来源:AbstractTransactionAspectTests.cs



注:本文中的Spring.Objects.TestObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Config.ConstructorArgumentValues类代码示例发布时间:2022-05-26
下一篇:
C# Objects.MutablePropertyValues类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap