Well, that kinda helped. When I register the test classes with the
container, I now get told that my methods must be marked virtual in order to
use transaction interception. Strange that I didn't have to do this other
places (out side of the test framework) that indeed work with the
transaction attribute. Is it trying to create a proxy? Why?
Even when marking them virtual, I still get no transaction from the manager.
For now, I'm just using .Net's TransactionScope around my test classes,
which defaults to rollback anyway. I'll reserve the [Transaction] attribute
for my application service classes where it appears to be working.
In the app service:
public class MyService
{
[Transaction]
public void AddItem(Item item)
{
_itemRepository.Add(item);
}
}
In the data unit test:
[TestClass]
public class ItemTests
{
[TestMethod]
public void AddItemTest()
{
using (new TransactionScope())
{
// my test code
}
}
}
It sure would be nice to do it the same way in both cases, but at least this
works for now.
Thanks,
Matt
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of gusgorman
Sent: Wednesday, November 09, 2011 8:11 AM
To: Castle Project Users
Subject: Re: How to explicitly roll back when using [Transaction] attribute
in AutoTx Facility?
> I can dig deeper into the source for AutoTx if someone can point me in the
> right direction. Where does the transaction actually get created? In
other
> words, what part of AutoTx actually looks for the [Transaction] attribute?
> I have a feeling that part of the code is not being invoked in my
scenario.
>
Hi Matt,
The object marked with the [Transaction] attribute needs to be in the
container. I would guess that your test class is not in the container,
and that is why no transaction has been started.
regards,
Jordan.
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.