-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved experience, warn forget Execute and pdb
- Loading branch information
1 parent
c631775
commit 5e59d95
Showing
4 changed files
with
207 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
tests/NetDaemon.Daemon.Tests/DaemonRunner/FaultyApp/ExecuteWarnings/MissingExecuteApp.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using JoySoftware.HomeAssistant.NetDaemon.Common; | ||
|
||
/// <summary> | ||
/// Greets (or insults) people when coming home :) | ||
/// </summary> | ||
public class MissingExecuteApp : NetDaemonApp | ||
{ | ||
public override async Task InitializeAsync() | ||
{ | ||
// Do nothing | ||
Entity("Test"); | ||
|
||
Entity("Test").TurnOn(); | ||
|
||
await Entity("jalll").TurnOn() | ||
.WithAttribute("test", "lslslsl").ExecuteAsync(); | ||
|
||
await TestFailInAMethod(); | ||
|
||
// Do rest of the needed commands the warning system needs to find | ||
Event("test").Call((a, b) => Task.CompletedTask); | ||
Events(n => n.EventId.StartsWith("hello_")).Call((a, b) => Task.CompletedTask); | ||
InputSelect("i").SetOption("test"); | ||
InputSelects(n => n.EntityId == "lslsls").SetOption("test"); | ||
MediaPlayer("i").Play(); | ||
MediaPlayers(n => n.EntityId == "lslsls").PlayPause(); | ||
Camera("sasdds").Snapshot("asdas"); | ||
Cameras(n => n.EntityId == "lslsls").Snapshot("asdas"); | ||
RunScript("test"); | ||
} | ||
|
||
private async Task TestFailInAMethod() | ||
{ | ||
await Entity("jalll").TurnOn() | ||
.WithAttribute("test", "lslslsl").ExecuteAsync(); | ||
|
||
Entity("jalll").WhenStateChange(to: "test") | ||
.AndNotChangeFor(System.TimeSpan.FromSeconds(1)) | ||
.Call(async (e, n, o) => | ||
{ | ||
Entity("Test").TurnOn(); | ||
var x = new NestedClass(this); | ||
await x.DoAThing(); | ||
}); | ||
|
||
} | ||
} | ||
|
||
public class NestedClass | ||
{ | ||
private readonly NetDaemonApp _app; | ||
|
||
public NestedClass(NetDaemonApp app) | ||
{ | ||
_app = app; | ||
} | ||
|
||
public async Task DoAThing() | ||
{ | ||
// Should find this error | ||
_app.Entities(new string[] { "test.test", "test.test2" }).TurnOn(); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/NetDaemon.Daemon.Tests/DaemonRunner/FaultyApp/ExecuteWarnings/MissingExecuteApp.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
missing_executes: | ||
class: MissingExecuteApp |