Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to disable load local assemblies #105

Merged
merged 2 commits into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/App/NetDaemon.App/NetDaemon.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JoySoftware.HassClient" Version="0.1.3-alpha" />
<PackageReference Include="JoySoftware.HassClient" Version="0.2.0-alpha" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.3" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Daemon/NetDaemon.Daemon/NetDaemon.Daemon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

</PropertyGroup>
<ItemGroup>
<PackageReference Include="JoySoftware.HassClient" Version="0.1.3-alpha" />
<PackageReference Include="JoySoftware.HassClient" Version="0.2.0-alpha" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/DaemonRunner/DaemonRunner/DaemonRunner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

</PropertyGroup>
<ItemGroup>
<PackageReference Include="JoySoftware.HassClient" Version="0.1.3-alpha" />
<PackageReference Include="JoySoftware.HassClient" Version="0.2.0-alpha" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.5.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" />
<PackageReference Include="YamlDotNet" Version="8.1.1" />
Expand Down
4 changes: 4 additions & 0 deletions src/DaemonRunner/DaemonRunner/Service/App/CodeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ public async Task<IEnumerable<INetDaemonApp>> InstanceAndInitApplications(INetDa

private void LoadLocalAssemblyApplicationsForDevelopment()
{
var disableLoadLocalAssemblies = Environment.GetEnvironmentVariable("HASS_DISABLE_LOCAL_ASM");
if (disableLoadLocalAssemblies is object && disableLoadLocalAssemblies == "true")
return;

// Get daemon apps in entry assembly (mainly for development)
var apps = Assembly.GetEntryAssembly()?.GetTypes().Where(type => type.IsClass && type.IsSubclassOf(typeof(NetDaemonApp)));
if (apps != null)
Expand Down
24 changes: 23 additions & 1 deletion tests/NetDaemon.Daemon.Tests/Fluent/FluentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,29 @@ public async Task EntityOnStateChangedLamdaTurnOnLightCallsCorrectServiceCall()
}

[Fact]
public async Task EntityOnStateChangedLamdaToggleLightCallsCorrectServiceCall()
public async Task EntityOnStateChangedLamdaWithMultipleEntitiesCallsCorrectServiceCall()
{
// ARRANGE
DefaultHassClientMock.AddChangedEvent("binary_sensor.pir", "off", "on");

var cancelSource = DefaultHassClientMock.GetSourceWithTimeout();
var MotionEnabled = true;

DefaultDaemonApp
.Entities(new string[] { "binary_sensor.pir", "binary_sensor-pir2" })
.WhenStateChange((to, from) => @from?.State == "off" && to?.State == "on" && MotionEnabled)
.UseEntity("light.correct_entity")
.Toggle()
.Execute();

await RunDefauldDaemonUntilCanceled();

DefaultHassClientMock.VerifyCallServiceTimes("toggle", Times.Once());
DefaultHassClientMock.VerifyCallService("light", "toggle", ("entity_id", "light.correct_entity"));
}

[Fact]
public async Task OneEntityWithSeveralShouldCallsCorrectServiceCall()
{
// ARRANGE
DefaultHassClientMock.AddChangedEvent("binary_sensor.pir", "off", "on");
Expand Down
2 changes: 1 addition & 1 deletion tests/NetDaemon.Daemon.Tests/NetDaemon.Daemon.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Moq" Version="4.14.0" />
<PackageReference Include="Moq" Version="4.14.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
Expand Down