Skip to content

Commit 608c369

Browse files
authored
Possible to disable load local assemblies (#105)
* Possible to disable load local assemblies * Upgraded moq dep
1 parent 2c9d3c2 commit 608c369

File tree

6 files changed

+31
-5
lines changed

6 files changed

+31
-5
lines changed

src/App/NetDaemon.App/NetDaemon.App.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</PropertyGroup>
2424

2525
<ItemGroup>
26-
<PackageReference Include="JoySoftware.HassClient" Version="0.1.3-alpha" />
26+
<PackageReference Include="JoySoftware.HassClient" Version="0.2.0-alpha" />
2727
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.3" />
2828
</ItemGroup>
2929

src/Daemon/NetDaemon.Daemon/NetDaemon.Daemon.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
</PropertyGroup>
2222
<ItemGroup>
23-
<PackageReference Include="JoySoftware.HassClient" Version="0.1.3-alpha" />
23+
<PackageReference Include="JoySoftware.HassClient" Version="0.2.0-alpha" />
2424
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" />
2525
</ItemGroup>
2626
<ItemGroup>

src/DaemonRunner/DaemonRunner/DaemonRunner.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
</PropertyGroup>
2323
<ItemGroup>
24-
<PackageReference Include="JoySoftware.HassClient" Version="0.1.3-alpha" />
24+
<PackageReference Include="JoySoftware.HassClient" Version="0.2.0-alpha" />
2525
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.5.0" />
2626
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" />
2727
<PackageReference Include="YamlDotNet" Version="8.1.1" />

src/DaemonRunner/DaemonRunner/Service/App/CodeManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ public async Task<IEnumerable<INetDaemonApp>> InstanceAndInitApplications(INetDa
427427

428428
private void LoadLocalAssemblyApplicationsForDevelopment()
429429
{
430+
var disableLoadLocalAssemblies = Environment.GetEnvironmentVariable("HASS_DISABLE_LOCAL_ASM");
431+
if (disableLoadLocalAssemblies is object && disableLoadLocalAssemblies == "true")
432+
return;
433+
430434
// Get daemon apps in entry assembly (mainly for development)
431435
var apps = Assembly.GetEntryAssembly()?.GetTypes().Where(type => type.IsClass && type.IsSubclassOf(typeof(NetDaemonApp)));
432436
if (apps != null)

tests/NetDaemon.Daemon.Tests/Fluent/FluentTests.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,29 @@ public async Task EntityOnStateChangedLamdaTurnOnLightCallsCorrectServiceCall()
7777
}
7878

7979
[Fact]
80-
public async Task EntityOnStateChangedLamdaToggleLightCallsCorrectServiceCall()
80+
public async Task EntityOnStateChangedLamdaWithMultipleEntitiesCallsCorrectServiceCall()
81+
{
82+
// ARRANGE
83+
DefaultHassClientMock.AddChangedEvent("binary_sensor.pir", "off", "on");
84+
85+
var cancelSource = DefaultHassClientMock.GetSourceWithTimeout();
86+
var MotionEnabled = true;
87+
88+
DefaultDaemonApp
89+
.Entities(new string[] { "binary_sensor.pir", "binary_sensor-pir2" })
90+
.WhenStateChange((to, from) => @from?.State == "off" && to?.State == "on" && MotionEnabled)
91+
.UseEntity("light.correct_entity")
92+
.Toggle()
93+
.Execute();
94+
95+
await RunDefauldDaemonUntilCanceled();
96+
97+
DefaultHassClientMock.VerifyCallServiceTimes("toggle", Times.Once());
98+
DefaultHassClientMock.VerifyCallService("light", "toggle", ("entity_id", "light.correct_entity"));
99+
}
100+
101+
[Fact]
102+
public async Task OneEntityWithSeveralShouldCallsCorrectServiceCall()
81103
{
82104
// ARRANGE
83105
DefaultHassClientMock.AddChangedEvent("binary_sensor.pir", "off", "on");

tests/NetDaemon.Daemon.Tests/NetDaemon.Daemon.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<PrivateAssets>all</PrivateAssets>
1818
</PackageReference>
1919
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
20-
<PackageReference Include="Moq" Version="4.14.0" />
20+
<PackageReference Include="Moq" Version="4.14.1" />
2121
<PackageReference Include="xunit" Version="2.4.1" />
2222
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
2323
<PrivateAssets>all</PrivateAssets>

0 commit comments

Comments
 (0)