本文整理汇总了C#中UnitOfWork.Begin方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.Begin方法的具体用法?C# UnitOfWork.Begin怎么用?C# UnitOfWork.Begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork.Begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldBeginNewTransaction
public void ShouldBeginNewTransaction()
{
// arrange
UnitOfWork uow = new UnitOfWork(m_session.Object);
// act
uow.Begin();
// assert
m_session.Verify(x => x.BeginTransaction());
}
示例2: ShouldBeginNewTransactionIfCurrentOneNotActive
public void ShouldBeginNewTransactionIfCurrentOneNotActive()
{
// arrange
UnitOfWork uow = new UnitOfWork(m_session.Object);
m_tx.Setup(x => x.IsActive).Returns(false);
m_session.Setup(x => x.Transaction).Returns(m_tx.Object);
// act
uow.Begin();
// assert
m_session.Verify(x => x.BeginTransaction());
}
示例3: ShouldEndIfBeginTransactionFails
public void ShouldEndIfBeginTransactionFails()
{
// arrange
m_session.Setup(x => x.BeginTransaction()).Throws(new HibernateException());
UnitOfWork uow = new UnitOfWork(m_session.Object);
// act
try
{
uow.Begin();
}
catch (HibernateException)
{
Assert.AreEqual(null, uow.Session);
return;
}
// assert
Assert.Fail("Begin did not throw exception");
}
示例4: ShouldNotBeginNewTransactionIfOneStillActive
public void ShouldNotBeginNewTransactionIfOneStillActive()
{
// arrange
m_session.Setup(x => x.Transaction).Returns(m_tx.Object);
UnitOfWork uow = new UnitOfWork(m_session.Object);
// act
uow.Begin();
// assert
m_session.Verify(x => x.BeginTransaction(), Times.Never());
}
示例5: Begin_Creates_Transaction
public void Begin_Creates_Transaction()
{
var uow = new UnitOfWork(_mockSession.Object);
uow.Begin();
_mockSession.Verify(s => s.BeginTransaction());
}