本文整理汇总了C#中Spring.Objects.TestObject类的典型用法代码示例。如果您正苦于以下问题:C# TestObject类的具体用法?C# TestObject怎么用?C# TestObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestObject类属于Spring.Objects命名空间,在下文中一共展示了TestObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: WithNonSerializableObject
public void WithNonSerializableObject()
{
TestObject o = new TestObject();
Assert.IsFalse(o is ISerializable);
Assert.IsFalse(IsSerializable(o));
Assert.Throws<SerializationException>(() => TrySerialization(o));
}
示例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);
}
示例4: WithNonSerializableObject
public void WithNonSerializableObject()
{
TestObject o = new TestObject();
Assert.IsFalse(o is ISerializable);
Assert.IsFalse(IsSerializable(o));
TrySerialization(o);
}
示例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);
}
示例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());
}
示例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;
}
示例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));
}
示例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.");
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}