using System; using System.Data; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using NSubstitute; using Volo.Abp.Modularity; using Volo.Abp.Testing; using Volo.Abp.Uow; using Xunit; namespace Volo.Abp.Data; public class DataSeederExtensions_Tests : AbpIntegratedTest { private IDataSeeder _dataSeeder; protected override void AfterAddApplication(IServiceCollection services) { _dataSeeder = Substitute.For(); services.Replace(ServiceDescriptor.Singleton(_dataSeeder)); base.AfterAddApplication(services); } [Fact] public void SeedInSeparateUowAsync() { var tenantId = Guid.NewGuid(); _dataSeeder.SeedInSeparateUowAsync(tenantId, new AbpUnitOfWorkOptions(true, IsolationLevel.Serializable, 888), true); _dataSeeder.Received().SeedAsync(Arg.Is(x => x.TenantId == tenantId && x.Properties[DataSeederExtensions.SeedInSeparateUow].To() == true && x.Properties[DataSeederExtensions.SeedInSeparateUowOptions].As().IsTransactional == true && x.Properties[DataSeederExtensions.SeedInSeparateUowOptions].As().IsolationLevel == IsolationLevel.Serializable && x.Properties[DataSeederExtensions.SeedInSeparateUowOptions].As().Timeout == 888 && x.Properties[DataSeederExtensions.SeedInSeparateUowRequiresNew].To() == true)); } [DependsOn(typeof(AbpDataModule))] public class TestModule : AbpModule { } }