public async Task Should_Get_Correct_Values()
        {
            var session = new MyChangableSession();

            var settingManager = CreateManager();

            settingManager.SettingStore = new MemorySettingStore();
            settingManager.AbpSession   = session;

            session.TenantId = 1;
            //继承测试

            session.UserId = 1;
            (await settingManager.GetSettingValueAsync(MyAllLevelsSetting)).ShouldBe("user 1 stored value");

            session.UserId = 2;
            (await settingManager.GetSettingValueAsync(MyAllLevelsSetting)).ShouldBe("user 2 stored value");
            //没有找到userid 为 3的设置,直接找的租户为1,用户为null的设置
            session.UserId = 3;
            (await settingManager.GetSettingValueAsync(MyAllLevelsSetting)).ShouldBe("tenant 1 stored value");
            //没有租户3用户3的设置,直接假设两个为null
            session.TenantId = 3;
            session.UserId   = 3;
            (await settingManager.GetSettingValueAsync(MyAllLevelsSetting)).ShouldBe("Application level stored value");
            //TODO: 没大搞懂
            session.TenantId = 1;
            session.UserId   = 1;
            (await settingManager.GetSettingValueForApplicationAsync(MyNotInheritedSetting)).ShouldBe("application value");
            (await settingManager.GetSettingValueForTenantAsync(MyNotInheritedSetting, session.TenantId.Value)).ShouldBe("default-value");
            (await settingManager.GetSettingValueAsync(MyNotInheritedSetting)).ShouldBe("default-value");
        }
        public async Task Should_Change_Setting_Values()
        {
            var session        = new MyChangableSession();
            var settingManager = CreateManager();

            settingManager.SettingStore = new MemorySettingStore();
            settingManager.AbpSession   = session;
            //应用程序级别修改
            await settingManager.ChangeSettingForApplicationAsync(MyAppLevelSetting, "53");

            await settingManager.ChangeSettingForApplicationAsync(MyAppLevelSetting, "54"); //修改两次应用程序级别设置

            await settingManager.ChangeSettingForApplicationAsync(MyAllLevelsSetting, "应用程序级别修改值");

            (await settingManager.SettingStore.GetSettingOrNullAsync(null, null, MyAppLevelSetting)).Value.ShouldBe("54");
            (await settingManager.GetSettingValueAsync <int>(MyAppLevelSetting)).ShouldBe(54);
            (await settingManager.GetSettingValueAsync(MyAllLevelsSetting)).ShouldBe("应用程序级别修改值");
            //租户级别修改
            session.TenantId = 1;
            await settingManager.ChangeSettingForTenantAsync(1, MyAllLevelsSetting, "租户1修改值");

            (await settingManager.GetSettingValueAsync(MyAllLevelsSetting)).ShouldBe("租户1修改值");
            //用户级别修改
            session.UserId = 5;
            await settingManager.ChangeSettingForUserAsync(5, MyAllLevelsSetting, "用户5修改值");

            (await settingManager.GetSettingValueAsync(MyAllLevelsSetting)).ShouldBe("用户5修改值");
        }
        public async Task Should_Delete_Setting_Values_On_Default_Value()
        {
            var session = new MyChangableSession();
            var store   = new MemorySettingStore();

            var settingManager = CreateManager();

            settingManager.SettingStore = store;
            settingManager.AbpSession   = session;

            session.TenantId = 1;
            session.UserId   = 1;
            //我们能获取到用户的个人存储值
            (await store.GetSettingOrNullAsync(1, 1, MyAllLevelsSetting)).ShouldNotBe(null);
            (await settingManager.GetSettingValueAsync(MyAllLevelsSetting)).ShouldBe("user 1 stored value");
            //这将为用户删除设置,因为它跟租户的设置相同
            await settingManager.ChangeSettingForUserAsync(1, MyAllLevelsSetting, "tenant 1 stored value");

            (await store.GetSettingOrNullAsync(1, 1, MyAllLevelsSetting)).ShouldBe(null);
            //我们能获取租户的设置值
            (await store.GetSettingOrNullAsync(1, null, MyAllLevelsSetting)).ShouldNotBe(null);
            (await settingManager.GetSettingValueAsync(MyAllLevelsSetting)).ShouldBe("tenant 1 stored value");
            //这将为租户删除设置,因为它跟应用程序级别设置相同
            await settingManager.ChangeSettingForTenantAsync(1, MyAllLevelsSetting, "Application level stored value");

            (await store.GetSettingOrNullAsync(1, 1, MyAllLevelsSetting)).ShouldBe(null);
            //我们获取应用程序设置
            (await store.GetSettingOrNullAsync(null, null, MyAllLevelsSetting)).ShouldNotBe(null);
            (await settingManager.GetSettingValueAsync(MyAllLevelsSetting)).ShouldBe("Application level stored value");
            //这将为应用程序删除设置,因为它跟默认设置相同
            await settingManager.ChangeSettingForApplicationAsync(MyAllLevelsSetting, "application level defalut value");

            (await store.GetSettingOrNullAsync(null, null, MyAllLevelsSetting)).ShouldBe(null);
            //没有设置值,就返回默认值
            (await settingManager.GetSettingValueAsync(MyAllLevelsSetting)).ShouldBe("application level defalut value");
        }