Beispiel #1
0
        public async Task Should_Delete_Person()
        {
            AbpSession.UserId = 1;

            var permissionChecker = Substitute.For <IPermissionChecker>();

            permissionChecker.IsGrantedAsync("CanDeletePerson").Returns(async info =>
            {
                await Task.Delay(10);
                return(true);
            });

            LocalIocManager.IocContainer.Register(
                Component.For <IPermissionChecker>().UsingFactoryMethod(() => permissionChecker).LifestyleSingleton()
                );

            var halil = await UsingDbContextAsync(async context => await context.People.SingleAsync(p => p.Name == "halil"));

            await _personAppService.DeletePerson(new EntityRequestInput(halil.Id));

            (await UsingDbContextAsync(async context => await context.People.FirstOrDefaultAsync(p => p.Name == "halil"))).ShouldBe(null);
        }