public void Create_Returns_Device_Proxy() { var device = Device.Create <Dummy>(); Assert.That(device, Is.InstanceOf <Dummy>()); Assert.That(DeviceProxy.IsProxy(device), Is.True); }
public async Task Find_Intercepts_Found_Devices() { var server = new Server(); server.SetFindFunction((input) => { return(Task.Run(() => (object)"[{\"id\":\"123\",\"type\":\"led\"}]")); }); var results = await server.Find <LED>("n/a"); var led = results.First(); Assert.That(DeviceProxy.IsProxy(led), Is.True); }
public void Resolver_Removes_Proxy_Interceptors() { var resolver = new ZettaInteropContractResolver(); var device = Device.Create <LED>(); var settings = new JsonSerializerSettings(); settings.ContractResolver = resolver; var json = JsonConvert.SerializeObject(device, settings); var properties = JObject.Parse(json).Properties() .Select((p) => p.Name).ToArray(); Assert.That(DeviceProxy.IsProxy(device), Is.True); Assert.That(properties, Has.No.Member("__interceptors")); }