Esempio n. 1
0
 /// <summary>
 /// 删除版本信息
 /// </summary>
 private async void Delete()
 {
     if (dataPager.SelectedItem is EditionListDto item)
     {
         if (await dialog.Question(Local.Localize("EditionDeleteWarningMessage", item.DisplayName)))
         {
             await SetBusyAsync(async() =>
             {
                 await WebRequest.Execute(() =>
                                          appService.DeleteEdition(new EntityDto(item.Id)),
                                          RefreshAsync);
             });
         }
     }
 }
        public async Task Should_Delete_Edition()
        {
            var editions = await _editionAppService.GetEditions();

            editions.Items.Count.ShouldBeGreaterThan(0);

            var defaultEdition = UsingDbContext(context => context.Editions.FirstOrDefault(e => e.Name == EditionManager.DefaultEditionName));
            await _editionAppService.DeleteEdition(new EntityDto(defaultEdition.Id));

            UsingDbContext(context =>
            {
                defaultEdition = context.Editions.FirstOrDefault(e => e.Name == EditionManager.DefaultEditionName);
                defaultEdition.ShouldNotBeNull();
                defaultEdition.IsDeleted.ShouldBe(true);

                context.Tenants.Count(t => t.EditionId == defaultEdition.Id).ShouldBe(0);
            });
        }
        public async Task Should_Not_Delete_Edition_If_There_Are_Subscriber_Tenants()
        {
            var editions = await _editionAppService.GetEditions();

            editions.Items.Count.ShouldBeGreaterThan(0);

            var defaultEdition = UsingDbContext(context => context.Editions.FirstOrDefault(e => e.Name == EditionManager.DefaultEditionName));

            var exception = await Assert.ThrowsAsync <UserFriendlyException>(async() => await _editionAppService.DeleteEdition(new EntityDto(defaultEdition.Id)));

            exception.Message.ShouldContain(_localizationManager.GetString(BukStoreConsts.LocalizationSourceName, "ThereAreTenantsSubscribedToThisEdition"));
        }
        public async Task Should_Not_Delete_Edition_If_There_Are_Subscriber_Tenants()
        {
            var editions = await _editionAppService.GetEditions();

            editions.Items.Count.ShouldBeGreaterThan(0);

            var defaultEdition = UsingDbContext(context => context.Editions.FirstOrDefault(e => e.Name == EditionManager.DefaultEditionName));

            var exception = await Assert.ThrowsAsync <UserFriendlyException>(async() => await _editionAppService.DeleteEdition(new EntityDto(defaultEdition.Id)));

            exception.Message.ShouldContain("There are tenants subscribed to this edition.");
        }