public DeregisterTest(ITestOutputHelper log) { this.logger = new Mock <ILogger>(); this.devices = new Mock <IDevices>(); this.scriptInterpreter = new Mock <IScriptInterpreter>(); this.rateLimitingConfig = new Mock <IRateLimitingConfig>(); this.deviceStateActor = new Mock <IDeviceStateActor>(); this.deviceConnectionActor = new Mock <IDeviceConnectionActor>(); this.loopSettings = new Mock <ConnectionLoopSettings>(this.rateLimitingConfig.Object); this.deviceModel = new DeviceModel { Id = DEVICE_ID }; this.target = new Deregister(this.devices.Object, this.logger.Object); }
private Task <MethodResult <Empty> > UnsubscribeEvent(ClientConnection clt, Deregister dat) { if (!clt.IsAuthenticated) { return(GetNotAuthedMessage()); } var i = GetEventInfo(dat.EndPoint); if (i == null) { return(GetEmptyErrorMessage("Endpoint not found")); } i.Subscribtions.Remove(clt); clt.SubscribedEvents.Remove(dat.EndPoint); TidyUpEventInfo(dat.EndPoint); return(GetEmptySuccessMessage()); }
private Task <MethodResult <Empty> > DeregisterMethod(ClientConnection clt, Deregister dat) { if (!clt.IsAuthenticated) { return(GetNotAuthedMessage()); } if (!_clientMethods.ContainsKey(dat.EndPoint)) { return(GetEmptyErrorMessage("Method endpoint unknown")); } if (!clt.Methods.Contains(dat.EndPoint)) { return(GetEmptyErrorMessage("Method not registered by this client!")); } clt.Methods.Remove(dat.EndPoint); _clientMethods.Remove(dat.EndPoint); return(GetEmptySuccessMessage()); }