Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
helto4real committed Mar 24, 2020
1 parent 0637ead commit 919f496
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/NetDaemon.Daemon.Tests/Demon/NetDaemonHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public async Task SpeakShouldWaitUntilMediaPlays()

// Add the player that we want to fake having with the fake playing 0.1 second media duration
dynamic currentStateAttributes = new ExpandoObject();
currentStateAttributes.media_duration = 0.6;
currentStateAttributes.media_duration = 0.1;

DefaultDaemonHost.InternalState["media_player.fakeplayer"] = new EntityState
{
Expand All @@ -244,16 +244,15 @@ public async Task SpeakShouldWaitUntilMediaPlays()

// ACT
DefaultDaemonHost.Speak("media_player.fakeplayer", "Hello test!");
await Task.Delay(100);
DefaultDaemonHost.Speak("media_player.fakeplayer", "Hello test!");

// ASSERT

// Called once after 150 ms
DefaultHassClientMock.Verify(n => n.CallService("tts", "google_cloud_say", expectedAttributesExpObject, true), Times.Once);
await Task.Delay(50);

await Task.Delay(1000);
DefaultHassClientMock.Verify(n => n.CallService("tts", "google_cloud_say", expectedAttributesExpObject, true), Times.Once);

await Task.Delay(100);
// Called twice
DefaultHassClientMock.Verify(n => n.CallService("tts", "google_cloud_say", expectedAttributesExpObject, true), Times.Exactly(2));

Expand Down

0 comments on commit 919f496

Please sign in to comment.