Browse Source

Added unit tes to see auto transaction behaviour for get/post requests.

pull/112/head
Halil İbrahim Kalkan 9 years ago
parent
commit
ececa994b0
  1. 11
      test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/UnitOfWorkTestController.cs
  2. 10
      test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Uow/UnitOfWorkMiddleware_Tests.cs

11
test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/UnitOfWorkTestController.cs

@ -12,6 +12,17 @@ namespace Volo.Abp.AspNetCore.App
public ActionResult ActionRequiresUow() public ActionResult ActionRequiresUow()
{ {
CurrentUnitOfWork.ShouldNotBeNull(); CurrentUnitOfWork.ShouldNotBeNull();
CurrentUnitOfWork.Options.IsTransactional.ShouldBeFalse();
return Content("OK");
}
[HttpPost]
[Route("ActionRequiresUowPost")]
public ActionResult ActionRequiresUowPost()
{
CurrentUnitOfWork.ShouldNotBeNull();
CurrentUnitOfWork.Options.IsTransactional.ShouldBeTrue();
return Content("OK"); return Content("OK");
} }

10
test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/Uow/UnitOfWorkMiddleware_Tests.cs

@ -1,4 +1,5 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Shouldly;
using Xunit; using Xunit;
namespace Volo.Abp.AspNetCore.Mvc.Uow namespace Volo.Abp.AspNetCore.Mvc.Uow
@ -6,9 +7,16 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
public class UnitOfWorkMiddleware_Tests : AspNetCoreMvcTestBase public class UnitOfWorkMiddleware_Tests : AspNetCoreMvcTestBase
{ {
[Fact] [Fact]
public async Task ActionRequiresUow() public async Task Get_Actions_Should_Not_Be_Transactional()
{ {
await GetResponseAsStringAsync("/api/unitofwork-test/ActionRequiresUow"); await GetResponseAsStringAsync("/api/unitofwork-test/ActionRequiresUow");
} }
[Fact]
public async Task Non_Get_Actions_Should_Be_Transactional()
{
var result = await Client.PostAsync("/api/unitofwork-test/ActionRequiresUowPost", null);
result.IsSuccessStatusCode.ShouldBeTrue();
}
} }
} }

Loading…
Cancel
Save