public void GetCachedFormatterResult_RunFirstUpdateNoChange() { IScriptFormatter scriptFormatter = this.RegisterScriptFormatterInManager("scriptFormatter"); scriptFormatter.HasCachedVariable.Returns(false); scriptFormatter.UpdateCachedVariable().Returns(false); IScriptFormatter scriptFormatterHooked = this.RegisterScriptFormatterInManager("scriptFormatterHooked"); scriptFormatterHooked.Hooks.Returns(new HashSet <string>() { "%scriptFormatter%" }); this.scriptsManager.GetCachedResult("%" + scriptFormatter.Id + "%"); scriptFormatter.Received(1).UpdateCachedVariable(); scriptFormatterHooked.Received(0).UpdateCachedVariable(); }
public virtual object GetCachedResult(string id) { if (!id.StartsWith("%") || !id.EndsWith("%")) { switch (id) { case "UIVersion": return(this.MumbleLinkFile.UIVersion); case "UITick": return(this.MumbleLinkFile.UITick); case "Name": return(this.MumbleLinkFile.Name); case "AvatarPosition": return(this.MumbleLinkFile.AvatarPosition.ToDictionary()); case "AvatarFront": return(this.MumbleLinkFile.AvatarFront.ToDictionary()); case "AvatarTop": return(this.MumbleLinkFile.AvatarTop.ToDictionary()); case "CameraPosition": return(this.MumbleLinkFile.CameraPosition.ToDictionary()); case "CameraFront": return(this.MumbleLinkFile.CameraFront.ToDictionary()); case "CameraTop": return(this.MumbleLinkFile.CameraTop.ToDictionary()); case "Description": return(this.MumbleLinkFile.Description); } if (this.MumbleLinkFile is Gw2MumbleLinkFile) { Gw2MumbleLinkFile gw2MumbleLinkFile = (Gw2MumbleLinkFile)this.MumbleLinkFile; switch (id) { case "CharacterName": return(gw2MumbleLinkFile.CharacterName); case "ProfessionId": return(gw2MumbleLinkFile.ProfessionId); case "MapId": return(gw2MumbleLinkFile.MapId); case "WorldId": return(gw2MumbleLinkFile.WorldId); case "TeamColorId": return(gw2MumbleLinkFile.TeamColorId); case "IsCommander": return(gw2MumbleLinkFile.IsCommander); case "ServerAddress": return(gw2MumbleLinkFile.ServerAddress.GetAddressBytes()); case "MapType": return(gw2MumbleLinkFile.MapType); case "ShardId": return(gw2MumbleLinkFile.ShardId); case "Instance": return(gw2MumbleLinkFile.Instance); case "BuildId": return(gw2MumbleLinkFile.BuildId); } } if (this.scriptVariables.ContainsKey(id)) { IScriptVariable script = this.scriptVariables[id]; if (!script.HasCachedVariable) { script.UpdateCachedVariable(); } return(script.CachedVariable); } } else { id = id.Substring(1, id.Length - 2); if (this.scriptFormatters.ContainsKey(id)) { IScriptFormatter script = this.scriptFormatters[id]; if (!script.HasCachedVariable) { script.UpdateCachedVariable(); } return(script.CachedVariable); } } return(null); }