public async Task EventShouldCallCorrectFunction() { // ARRANGE await InitializeFakeDaemon().ConfigureAwait(false); dynamic helloWorldDataObject = GetDynamicDataObject(HelloWorldData); DefaultHassClientMock.AddCustomEvent("CUSTOM_EVENT", helloWorldDataObject); var isCalled = false; var message = ""; // ACT DefaultDaemonApp.ListenEvent("CUSTOM_EVENT", (ev, data) => { isCalled = true; message = data.Test; return(Task.CompletedTask); }); await RunFakeDaemonUntilTimeout().ConfigureAwait(false); // ASSERT Assert.True(isCalled); Assert.Equal(HelloWorldData, message); }
public async Task OtherEventShouldNotCallCorrectFunction() { // ARRANGE await InitializeFakeDaemon().ConfigureAwait(false); dynamic dataObject = GetDynamicDataObject(); DefaultHassClientMock.AddCustomEvent("CUSTOM_EVENT", dataObject); var isCalled = false; // ACT DefaultDaemonApp.ListenEvent("OTHER_EVENT", (ev, data) => { isCalled = true; return(Task.CompletedTask); }); await RunFakeDaemonUntilTimeout().ConfigureAwait(false); // ASSERT Assert.False(isCalled); }