Ebbe a problémába én is belefutottam. Nem volt könnyű rájönni a megoldásra.
Én akkor nem írtam le, de más megtette: http://bit.ly/3JF5dp
Még jól jöhet.
Szakmai és kevésbé szakmai bejegyzések webes térképekről, szoftverfejlesztésről, térinformatikáról meg csak úgy...
Ebbe a problémába én is belefutottam. Nem volt könnyű rájönni a megoldásra.
Én akkor nem írtam le, de más megtette: http://bit.ly/3JF5dp
Még jól jöhet.
[TestFixture]
public class DBTest
{
[SetUp]
public void Setup()
{
// Enter a new transaction without inheriting from ServicedComponent
Console.WriteLine("Attempting to enter a transactional context...");
ServiceConfig config = new ServiceConfig();
config.Transaction = TransactionOption.RequiresNew;
ServiceDomain.Enter(config);
Console.WriteLine("Attempt suceeded!");
}
[Test]
public void Insert()
{
// Perform your magic against the database
CategoriesManager mgr = new CategoriesManager();
int newID = mgr.InsertCategory("MyCategory");
Assert.IsTrue(newID != 0, "returned ID should be more than zero");
}
[TearDown]
public void Teardown()
{
Console.WriteLine("Attempting to Leave transactional context...");
if (ContextUtil.IsInTransaction)
{
// Abort the running transaction
ContextUtil.SetAbort();
}
ServiceDomain.Leave();
Console.WriteLine("Left context!");
// Trying to access ContextUtil now will yield an exception
}
}