public async Task Provision_Ensures_Type_Is_Set() { var input = new MockInput(); var server = new MockServer(); input.provision = (obj) => { var interop = (DevicePayload)obj; var json = JObject.Parse(interop.Properties); Assert.That(json.GetValue("type").ToString(), Is.EqualTo("led")); return(Task.Run(() => (object)null)); }; server.find = (i) => { return(Task.Run(() => (object)"[{\"id\":\"123\"}]")); }; server.prepare = (i) => { return(Task.Run(() => (object)i)); }; input.server = server; var loader = ScoutLoader.Create(input); await loader.Use(new LEDScout()); }
public async Task Use_Sets_Discover_Function_From_Loader() { var input = new MockInput(); var server = new MockServer(); var hasRun = false; server.find = (i) => { return(Task.Run(() => (object)"[]")); }; input.server = server; input.discover = (obj) => Task.Run(() => { hasRun = true; return((object)null); }); input.provision = (obj) => Task.Run(() => { return((object)null); }); var loader = ScoutLoader.Create(input); var scout = new LEDScout(); await loader.Use(scout); await scout.Discover(Device.Create <LED>()).ContinueWith((obj) => { Assert.That(hasRun, Is.True); }); }
public async Task Provision_Function_Is_Set() { var input = new MockInput(); var server = new MockServer(); var hasRun = false; input.provision = (obj) => { hasRun = true; return(Task.Run(() => (object)null)); }; server.find = (i) => { return(Task.Run(() => (object)"[{\"id\":\"1234\"}]")); }; input.server = server; var loader = ScoutLoader.Create(input); await loader.Use(new LEDScout()).ContinueWith((i) => { Assert.That(hasRun, Is.True); }); }