You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuEfTransactionScopeTest.cs 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using Luticate2.Utils.Dbo.Result;
  3. using Microsoft.Extensions.DependencyInjection;
  4. using TestUtils.DataAccess;
  5. using TestUtils.Dbo.PkGuid;
  6. using Xunit;
  7. namespace TestUtils.EfCrudDataAccess
  8. {
  9. public class LuEfTransactionScopeTest
  10. {
  11. [Fact]
  12. public void TestAddDboSingle1()
  13. {
  14. var serviceProvider = Tests.BuildServiceProvider();
  15. var service = serviceProvider.GetService<LuUtilsPkGuidDataAccess>();
  16. var transact = service.BeginTransaction(null);
  17. var res = service.AddDbo(new PkGuidAddDbo
  18. {
  19. SomeInt = 42,
  20. SomeText = "Test."
  21. });
  22. Assert.Equal(LuStatus.Success, res.Status);
  23. Assert.NotEqual(new Guid().ToString(), res.Data.Id);
  24. var get = service.GetSingleById(res.Data.Id);
  25. Assert.Equal(LuStatus.Success, get.Status);
  26. service.RollbackTransaction(transact);
  27. get = service.GetSingleById(res.Data.Id);
  28. Assert.Equal(LuStatus.NotFound, get.Status);
  29. }
  30. }
  31. }