Browse Source

Framework - Add DeleteMany Tests to HardDelete_Tests

pull/7478/head
enisn 6 years ago
parent
commit
8aa48e7644
  1. 37
      framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/HardDelete_Tests.cs

37
framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/HardDelete_Tests.cs

@ -1,7 +1,9 @@
using Shouldly;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Modularity;
using Volo.Abp.TestApp.Domain;
@ -119,5 +121,40 @@ namespace Volo.Abp.TestApp.Testing
john.ShouldBeNull();
}
}
[Fact]
public async Task Should_HardDelete_WithDeleteMany()
{
var persons = await PersonRepository.GetListAsync();
await WithUnitOfWorkAsync(async () =>
{
var hardDeleteEntities = (HashSet<IEntity>)UnitOfWorkManager.Current.Items.GetOrAdd(
UnitOfWorkItemNames.HardDeletedEntities,
() => new HashSet<IEntity>()
);
hardDeleteEntities.UnionWith(persons);
await PersonRepository.DeleteManyAsync(persons);
});
var personsCount = await PersonRepository.GetCountAsync();
personsCount.ShouldBe(0);
}
[Fact]
public async Task Should_HardDelete_WithDeleteMany_WithPredicate()
{
await WithUnitOfWorkAsync(async () =>
{
await PersonRepository.HardDeleteAsync(x => x.Id == TestDataBuilder.UserDouglasId);
await PersonRepository.DeleteManyAsync(new[] { TestDataBuilder.UserDouglasId });
});
var douglas = await PersonRepository.FindAsync(TestDataBuilder.UserDouglasId);
douglas.ShouldBeNull();
}
}
}

Loading…
Cancel
Save