protected override void RunTest(Action <RuntimeConfig> runtimeConfigCustomizer, string testAssemblyName, string appAsmVersion, string appFileVersion, string frameworkWins) { var app = SharedState.CreateTestFrameworkReferenceApp(b => b .WithPackage(TestVersionsPackage, "1.0.0", lib => lib .WithAssemblyGroup(null, g => g .WithAsset(testAssemblyName + ".dll", rf => rf .WithVersion(appAsmVersion, appFileVersion))))); if (runtimeConfigCustomizer is not null) { var runtimeConfig = new RuntimeConfig(app.RuntimeConfigJson); runtimeConfigCustomizer(runtimeConfig); runtimeConfig.Save(); } string expectedBaseLocation = frameworkWins switch { MicrosoftNETCoreApp => SharedState.DotNetWithNetCoreApp.GreatestVersionSharedFxPath, HighWare => Path.Combine(SharedState.DotNetWithNetCoreApp.BinPath, "shared", HighWare, "1.1.1"), _ => app.Location, }; string expectedTestAssemblyPath = Path.Combine(expectedBaseLocation, testAssemblyName + ".dll"); SharedState.DotNetWithNetCoreApp.Exec(app.AppDll) .EnableTracingAndCaptureOutputs() .Execute() .Should().Pass() .And.HaveResolvedAssembly(expectedTestAssemblyPath); }
public DotNetFramework RuntimeConfig(Action <RuntimeConfig> runtimeConfigCustomizer) { string runtimeConfigPath = Path.Combine(_path, _name + ".runtimeconfig.json"); _backup.Backup(runtimeConfigPath); RuntimeConfig runtimeConfig = HostActivation.RuntimeConfig.FromFile(runtimeConfigPath); runtimeConfigCustomizer(runtimeConfig); runtimeConfig.Save(); return(this); }
public void ProcessGroupMessage(GroupMessageReceivedContext context) { var managerQQ = RuntimeConfig.Config.ManagerQq.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var message = context.Message; var fromQQ = context.FromQq; var group = context.FromGroup; var loginQQ = _mahuaApi.GetLoginQq(); if (managerQQ.Any(x => x == fromQQ)) { var ats = CQNumberHelper.GetAtQQ(context.Message)?.ToList(); if (!ats?.Any(x => x == loginQQ) ?? false) { return; } //解除禁言 if (message.IndexOf("解除禁言") > -1) { foreach (var item in ats.Where(x => x != loginQQ)) { _mahuaApi.RemoveBanGroupMember(group, item); } } else { var m = banRegex.Match(message); //禁言 if (m.Success) { var time = Convert.ToDouble(m.Groups[1].Value); foreach (var item in ats?.Where(x => x != loginQQ)) { _mahuaApi.BanGroupMember(context.FromGroup, item, TimeSpan.FromMinutes(time)); } return; } //修改复读禁言时间 m = repeatBanTimeChangeRegex.Match(message); if (m.Success) { var time = Convert.ToDouble(m.Groups[1].Value); if (time > 0) { RuntimeConfig.Config.RepeatMessageBanDuration = time; RuntimeConfig.Save(AppSetting.ConfigFilePath, RuntimeConfig.Config.ToJosn()); } return; } //修改复读禁言概率 m = repeatBanProbabilityChangeRegex.Match(message); if (m.Success) { var time = Convert.ToDouble(m.Groups[1].Value); if (time > 0) { RuntimeConfig.Config.RepeatMessageBanProbability = time; RuntimeConfig.Save(AppSetting.ConfigFilePath, RuntimeConfig.Config.ToJosn()); } return; } } } }