|
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Yap.Data.Client;
namespace Yap.Data.UnitTest
{
[TestClass]
public class TransactionScopeTestFixture
{
[TestMethod]
[ExpectedException(typeof(InvalidOperationException))]
public void Constructor_ParentScopeIsNotSessionOrTransaction_ThrowInvalidOperationException()
{
new TransactionScope();
}
[TestMethod]
public void Constructor__NameShouldBeSetAccordinglyToNestingLevel()
{
using (new SessionScope())
{
using (var t0 = new TransactionScope())
{
Assert.AreEqual("T0", t0.Name);
using (var t00 = new TransactionScope())
{
Assert.AreEqual("T0-0", t00.Name);
using (var t000 = new TransactionScope())
{
Assert.AreEqual("T0-0-0", t000.Name);
t000.Rollback();
}
using (var t001 = new TransactionScope())
{
Assert.AreEqual("T0-0-1", t001.Name);
t001.Rollback();
}
t00.Rollback();
}
using (var t01 = new TransactionScope())
{
Assert.AreEqual("T0-1", t01.Name);
using (var t010 = new TransactionScope())
{
Assert.AreEqual("T0-1-0", t010.Name);
}
using (var t011 = new TransactionScope())
{
Assert.AreEqual("T0-1-1", t011.Name);
}
}
t0.Rollback();
}
using (var t0 = new TransactionScope())
{
Assert.AreEqual("T0", t0.Name);
}
}
}
[TestMethod]
public void get_Session__ReturnParentSession()
{
using (var session = new SessionScope())
{
using (var t0 = new TransactionScope())
{
Assert.AreSame(session, t0.Session);
using (var t00 = new TransactionScope())
{
Assert.AreSame(session, t00.Session);
}
using (var t01 = new TransactionScope())
{
Assert.AreSame(session, t01.Session);
}
}
using (var t0 = new TransactionScope())
{
Assert.AreSame(session, t0.Session);
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.