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.

66 lines
2.2 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. using NSubstitute;
  2. using Shentun.Peis.EntityFrameworkCore;
  3. using Shentun.Peis.GuidTypes;
  4. using Shentun.Peis.ItemTypes;
  5. using Shentun.Peis.Models;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using Volo.Abp.Domain.Repositories;
  12. using Volo.Abp.EntityFrameworkCore;
  13. using Volo.Abp.Uow;
  14. using Xunit;
  15. namespace Shentun.Peis
  16. {
  17. public class GuideTypeManagerTest : PeisDomainTestBase
  18. {
  19. private readonly IRepository<GuideType, Guid> _repository;
  20. private readonly GuideTypeManager _manager;
  21. private readonly IDbContextProvider<PeisDbContext> _dbContextProvider;
  22. private readonly IUnitOfWorkManager _unitOfWorkManager;
  23. public GuideTypeManagerTest()
  24. {
  25. _repository = Substitute.For<IRepository<GuideType,Guid>>();
  26. //_repository = GetRequiredService<IRepository<GuideType, Guid>>();
  27. _manager = GetRequiredService<GuideTypeManager>();
  28. //_dbContextProvider = GetRequiredService<IDbContextProvider<PeisDbContext>>();
  29. //_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
  30. }
  31. [Fact]
  32. public async Task Should_Set_CanAdd()
  33. {
  34. var createEntity = new GuideType();
  35. createEntity.DisplayName = "normal";
  36. var item = await _manager.CreateAsync(createEntity);
  37. item = await _repository.InsertAsync(item,true);
  38. if(item != null)
  39. {
  40. Console.WriteLine(item.Id.ToString());
  41. }
  42. }
  43. [Fact]
  44. public async Task Should_Set_CanAdd_Sync()
  45. {
  46. var createEntity = new GuideType();
  47. createEntity.DisplayName = "normal";
  48. var item = await _manager.CreateAsync(createEntity);
  49. item = _repository.InsertAsync(item, true).Result;
  50. Console.WriteLine(item.Id.ToString());
  51. }
  52. [Fact]
  53. public async Task TestDataBase()
  54. {
  55. var db = await _dbContextProvider.GetDbContextAsync();
  56. var items = db.Users.ToList();
  57. items.ForEach(o =>
  58. {
  59. Console.WriteLine(o.Id.ToString());
  60. });
  61. }
  62. }
  63. }