public async Task Should_Create_Edition()
        {
            //Getting edition for edit
            var output = await _editionAppService.GetEditionForEdit(new NullableIdDto(null));

            //Changing a sample feature value
            var chatFeature = output.FeatureValues.FirstOrDefault(f => f.Name == AppFeatures.ChatFeature);

            if (chatFeature != null)
            {
                chatFeature.Value = chatFeature.Value = "true";
            }

            await _editionAppService.CreateOrUpdateEdition(
                new CreateOrUpdateEditionDto
            {
                Edition = new EditionEditDto
                {
                    DisplayName = "Premium Edition"
                },
                FeatureValues = output.FeatureValues
            });

            await UsingDbContextAsync(async context =>
            {
                var premiumEditon = await context.Editions.FirstOrDefaultAsync(e => e.DisplayName == "Premium Edition");
                premiumEditon.ShouldNotBeNull();

                if (chatFeature != null)
                {
                    var sampleFeatureValue = context.EditionFeatureSettings.FirstOrDefault(s => s.EditionId == premiumEditon.Id && s.Name == AppFeatures.ChatFeature);
                    sampleFeatureValue.ShouldNotBe(null);
                    sampleFeatureValue.Value.ShouldBe("true");
                }
            });
        }
Exemplo n.º 2
0
        public async Task Should_Not_Create_User_More_Than_Allowed_Count()
        {
            //Getting edition for edit
            var output = await _editionAppService.GetEditionForEdit(new NullableIdDto(null));

            //Changing a sample feature value
            var maxUserCountFeature = output.FeatureValues.FirstOrDefault(f => f.Name == AppFeatures.MaxUserCount);

            if (maxUserCountFeature != null)
            {
                maxUserCountFeature.Value = "2";
            }

            await _editionAppService.CreateOrUpdateEdition(
                new CreateOrUpdateEditionDto
            {
                Edition = new EditionEditDto
                {
                    DisplayName = "Premium Edition"
                },
                FeatureValues = output.FeatureValues
            });


            var premiumEditon = (await _editionAppService.GetEditions()).Items.FirstOrDefault(e => e.DisplayName == "Premium Edition");

            premiumEditon.ShouldNotBeNull();

            await UsingDbContextAsync(async context =>
            {
                var tenant       = await context.Tenants.SingleAsync(t => t.TenancyName == AbpTenantBase.DefaultTenantName);
                tenant.EditionId = premiumEditon.Id;

                context.SaveChanges();
            });

            LoginAsDefaultTenantAdmin();

            // This is second user (first is tenant admin)
            await _userAppService.CreateOrUpdateUser(
                new CreateOrUpdateUserInput
            {
                User = new UserEditDto
                {
                    EmailAddress = "*****@*****.**",
                    Name         = "John",
                    Surname      = "Nash",
                    UserName     = "******",
                    Password     = "******"
                },
                AssignedRoleNames = new string[] { }
            });

            //Act
            var exception = await Assert.ThrowsAsync <UserFriendlyException>(
                async() =>
                await _userAppService.CreateOrUpdateUser(
                    new CreateOrUpdateUserInput
            {
                User = new UserEditDto
                {
                    EmailAddress = "*****@*****.**",
                    Name         = "Ali Rıza",
                    Surname      = "Adıyahşi",
                    UserName     = "******",
                    Password     = "******"
                },
                AssignedRoleNames = new string[] { }
            })
                );

            exception.Message.ShouldContain(_localizationManager.GetString(FileManagementConsts.LocalizationSourceName, "MaximumUserCount_Error_Message"));
        }