test(upserver): 归档存档迁移与玩法闭环回归工具
This commit is contained in:
1
CodexOutput/upserver/HomeExitTests/HomeExitTests.csproj
Normal file
1
CodexOutput/upserver/HomeExitTests/HomeExitTests.csproj
Normal file
@@ -0,0 +1 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net9.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><RestoreConfigFile>$(MSBuildThisFileDirectory)../MinimalLoginTests/NuGet.Config</RestoreConfigFile></PropertyGroup></Project>
|
||||
29
CodexOutput/upserver/HomeExitTests/Program.cs
Normal file
29
CodexOutput/upserver/HomeExitTests/Program.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
void Check(bool value,string message){if(!value)throw new Exception(message);}
|
||||
foreach(var scenario in new[]{"normal","destroyed","replaced"}){
|
||||
GContext.container=new Container();Awaiters.Gate=new();var old=GContext.container;var panel=new Subject();
|
||||
var pending=panel.LastShowPanel();Check(!pending.IsCompleted,"expected delay");
|
||||
if(scenario=="destroyed")panel.Destroyed=true;
|
||||
if(scenario=="replaced")GContext.container=new Container();
|
||||
Awaiters.Gate.SetResult(true);await pending;
|
||||
Check(old.Face.Shows==(scenario=="normal"?1:0),"old flow applied after exit");
|
||||
if(scenario=="replaced")Check(GContext.container.Face.Shows==0,"old callback opened new account UI");
|
||||
Check(Debug.Errors==0,"callback logged an error");
|
||||
Console.WriteLine("PASS real LastShowPanel body: "+scenario);
|
||||
}
|
||||
public partial class Subject{
|
||||
public bool Destroyed;
|
||||
public static bool operator ==(Subject a,Subject b)=>ReferenceEquals(b,null)?ReferenceEquals(a,null)||a.Destroyed:ReferenceEquals(a,b);
|
||||
public static bool operator !=(Subject a,Subject b)=>!(a==b);
|
||||
public override bool Equals(object other)=>ReferenceEquals(this,other);
|
||||
public override int GetHashCode()=>base.GetHashCode();
|
||||
}
|
||||
public static class GContext{public static Container container=new();}
|
||||
public class Container{
|
||||
public Face Face=new();public BuffDataCenter Buff=new();
|
||||
public T Resolve<T>()=>(T)(object)(typeof(T)==typeof(BuffDataCenter)?(object)Buff:Face);
|
||||
}
|
||||
public class BuffDataCenter{public List<int> showFishBuffIds=new();}
|
||||
public interface IFaceUIService{void ShowPostFaceUI();}
|
||||
public class Face:IFaceUIService{public int Shows;public void ShowPostFaceUI()=>Shows++;}
|
||||
public static class Awaiters{public static TaskCompletionSource<bool> Gate;public static Task Seconds(float n)=>Gate.Task;}
|
||||
public static class Debug{public static int Errors;public static void LogError(object e)=>Errors++;}
|
||||
7
CodexOutput/upserver/HomeExitTests/generate.py
Normal file
7
CodexOutput/upserver/HomeExitTests/generate.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from pathlib import Path
|
||||
s=Path('Client/Assets/Scripts/UI/Home/HomePanel.cs').read_text(encoding='utf-8-sig')
|
||||
start=s.index('async void LastShowPanel()'); a=s.index('{',start); n=1; end=a+1
|
||||
while n:
|
||||
n+=(s[end]=='{')-(s[end]=='}'); end+=1
|
||||
method=s[start:end].replace('async void LastShowPanel()', 'public async Task LastShowPanel()')
|
||||
Path('CodexOutput/upserver/HomeExitTests/Generated.cs').write_text('using System;using System.Threading.Tasks;public partial class Subject {\n'+method+'\n}',encoding='utf-8')
|
||||
Reference in New Issue
Block a user