test(upserver): 归档存档迁移与玩法闭环回归工具
This commit is contained in:
19
CodexOutput/upserver/LogoutStorageTests/Program.cs
Normal file
19
CodexOutput/upserver/LogoutStorageTests/Program.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
void Check(bool value,string message){if(!value)throw new Exception(message);}
|
||||
var s=new Subject();var pending=new Dictionary<string,string>{{"existing-key","existing-data"}};
|
||||
s.dataBuffer.AddLast(pending);var spare=s.swapData;
|
||||
PlayFabClientAPI.LoggedIn=false;s.Flush();
|
||||
Check(PlayFabClientAPI.Calls==0&&ReferenceEquals(pending,s.dataBuffer.First.Value)&&ReferenceEquals(spare,s.swapData),"unauthorized flush changed queue");
|
||||
var token=s.tokenSource.Token;s.Destroy();
|
||||
Check(token.IsCancellationRequested&&s.tokenSource==null&&PlayerPrefs.Saves==1,"destroy must cancel and save local cache");
|
||||
Check(PlayFabClientAPI.Calls==0&&pending["existing-key"]=="existing-data","destroy discarded pending data or uploaded without auth");
|
||||
PlayFabClientAPI.LoggedIn=true;s.Flush();
|
||||
Check(PlayFabClientAPI.Calls==1&&PlayFabClientAPI.Last.Data["existing-key"]=="existing-data","authorized upload regressed");
|
||||
Console.WriteLine("PASS real SyncData/OnDestroy: unauthenticated queue unchanged, local Save, cancellation and authorized upload");
|
||||
public static class PlayerPrefs{public static int Saves;public static void Save()=>Saves++;}
|
||||
public class UpdateUserDataRequest{public Dictionary<string,string> Data;public UserDataPermission Permission;}
|
||||
public enum UserDataPermission{Public}
|
||||
public static class PlayFabClientAPI{
|
||||
public static bool LoggedIn;public static int Calls;public static UpdateUserDataRequest Last;
|
||||
public static bool IsClientLoggedIn()=>LoggedIn;
|
||||
public static void UpdateUserData(UpdateUserDataRequest request,Action<object> ok,Action<object> fail){if(!LoggedIn)throw new Exception("not logged in");Calls++;Last=request;}
|
||||
}
|
||||
Reference in New Issue
Block a user