Thanks Ryan,
But that is how I have it. I just copied this unit test from aspnetboilerplate repository. The same code works here as expected. But not in my aspnetzero project.
Tests_For_EntityChangeEvents.cs
see below updated test for another repository:
[Fact]
public void Should_Rollback_UOW_In_Updating_Event()
{
//Arrange
var updatingTriggerCount = 0;
var updatedTriggerCount = 0;
Resolve<IEventBus>().Register<EntityUpdatingEventData<Facility>>(
eventData =>
{
eventData.Entity.Name.Should().Be("Facility 2");
updatingTriggerCount++;
throw new ApplicationException("A sample exception to rollback the UOW.");
});
Resolve<IEventBus>().Register<EntityUpdatedEventData<Facility>>(
eventData =>
{
//Should not come here, since UOW is failed
updatedTriggerCount++;
});
//Act
Action action = () =>
{
using (var uow = Resolve<IUnitOfWorkManager>().Begin())
{
var facility = _facilityRepository.Single(p => p.Name == "Facility");
facility.Name = "Facility 2";
_facilityRepository.Update(facility);
uow.Complete();
}
Assert.True(false, "Should not come here since ApplicationException is thrown!");
};
action
.Should()
.Throw<ApplicationException>();
//Assert
updatingTriggerCount.Should().Be(1);
updatedTriggerCount.Should().Be(0);
_facilityRepository
.FirstOrDefault(p => p.Name == "Facility")
.Should()
.NotBeNull("should not be changed since we throw exception to rollback the transaction");
}
Thanks. I've updated flaticon folder with the new version and now it's all ok.
<cite>yekalkan: </cite> 3) see <a class="postlink" href="https://github.com/aspnetzero/aspnet-ze">https://github.com/aspnetzero/aspnet-ze</a> ... -381206936
Thanks