18 lines
1.4 KiB
C#
18 lines
1.4 KiB
C#
void Assert(bool ok,string name){if(!ok)throw new Exception(name);}
|
|
foreach(var json in new string[]{null,"","[]","{}","bad","{\"clubInfo\":false}","{\"clubInfo\":{\"id\":0}}","{\"clubInfo\":{\"id\":8}}"}){
|
|
var s=new Subject();var old=s.myClubInfo;s.customServerMgr.Response=json;s.GetSelfClub();Assert(ReferenceEquals(old,s.myClubInfo)&&s.Effects==0,"Invalid response must preserve known state: "+json);
|
|
}
|
|
{
|
|
var s=new Subject();s.userService.IsAuthorized=false;s.GetSelfClub();Assert(s.customServerMgr.Calls==0,"No unauthorized request");
|
|
}
|
|
{
|
|
var s=new Subject();s.customServerMgr.Response="{\"clubInfo\":null}";s.GetSelfClub();Assert(s.myClubInfo==null && s.customServerMgr.Request.playerId=="101","Explicit no club and correct identity");
|
|
}
|
|
{
|
|
var s=new Subject();var old=s.myClubInfo;s.customServerMgr.Gate=new();s.GetSelfClub();s.customServerMgr.SessionVersion++;s.customServerMgr.Gate.SetResult("{\"clubInfo\":null}");Assert(ReferenceEquals(old,s.myClubInfo)&&s.Effects==0,"Old response ignored");
|
|
}
|
|
{
|
|
var s=new Subject();s.customServerMgr.Response="{\"clubInfo\":{\"id\":8},\"role\":2,\"playerIDs\":{\"42\":\"101\"}}";s.GetSelfClub();Assert(s.myClubInfo.id==8 && s.memberRole==EMemberRole.Member && s.chatService.Calls==1 && s.internalIdToPlayerId[42]=="101","Valid member response applied");
|
|
}
|
|
Console.WriteLine("PASS home GetSelfClub: identity, unauthorized, failed/missing responses, explicit no-club, old response isolation");
|