Skip to content
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
9 changes: 8 additions & 1 deletion src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
<PackageReference Include="NServiceBus" Version="8.0.3" />
<PackageReference Include="NServiceBus" Version="8.1.1" />
<PackageReference Include="NServiceBus.Transport.AzureServiceBus" Version="3.2.0" />
</ItemGroup>

Expand All @@ -25,6 +25,13 @@
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<!-- Prevent Functions from removing NServiceBus dependencies that it thinks are included "in the box" -->
<FunctionsPreservedDependencies Include="System.Diagnostics.DiagnosticSource.dll" />
<FunctionsPreservedDependencies Include="System.Text.Json.dll" />
<FunctionsPreservedDependencies Include="System.Text.Encodings.Web.dll" />
</ItemGroup>

<ItemGroup>
<None Update="host.json" CopyToOutputDirectory="PreserveNewest" />
<None Update="local.settings.json" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="Never" />
Expand Down
48 changes: 45 additions & 3 deletions src/IntegrationTests.HostV4/When_starting_the_function_host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Azure.Messaging.ServiceBus.Administration;
using Microsoft.Extensions.Configuration;
using NUnit.Framework;

[TestFixture]
Expand All @@ -15,10 +17,50 @@ public class When_starting_the_function_host
[Test]
public async Task Should_not_blow_up()
{
var pathToFuncExe = Environment.GetEnvironmentVariable("PathToFuncExe");
Assert.IsNotNull(pathToFuncExe, "Environment variable 'PathToFuncExe' should be defined to run tests. When running locally this is usually 'C:\\Users\\MyUser\\AppData\\Local\\AzureFunctionsTools\\Releases\\4.30.0\\cli_x64\\func.exe'");
var configBuilder = new ConfigurationBuilder();
configBuilder.SetBasePath(Directory.GetCurrentDirectory());
configBuilder.AddEnvironmentVariables();
configBuilder.AddJsonFile("local.settings.json", true);

var connectionString = Environment.GetEnvironmentVariable("AzureWebJobsServiceBus");
var config = configBuilder.Build();

var pathToFuncExe = config.GetValue<string>("PathToFuncExe");

if (pathToFuncExe == null)
{
Console.WriteLine("Environment variable 'PathToFuncExe' not defined. Going to try to find the latest version.");

var userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
var sdkPath = Path.Combine(userProfile, "AppData", "Local", "AzureFunctionsTools", "Releases");
if (Directory.Exists(sdkPath))
{
var mostRecent = Directory.GetDirectories(sdkPath)
.Select(path =>
{
var name = Path.GetFileName(path);
Version.TryParse(name, out var version);
return new { Name = name, Version = version };
})
.Where(x => x.Version is not null)
.OrderByDescending(x => x.Version)
.FirstOrDefault()
?.Name;

if (mostRecent is not null)
{
var exePath = Path.Combine(sdkPath, mostRecent, "cli_x64", "func.exe");
if (File.Exists(exePath))
{
Console.WriteLine("Found " + exePath);
pathToFuncExe = exePath;
}
}
}
}

Assert.IsNotNull(pathToFuncExe, "Environment variable 'PathToFuncExe' should be defined to run tests. When running locally this is usually 'C:\\Users\\<username>\\AppData\\Local\\AzureFunctionsTools\\Releases\\<version>\\cli_x64\\func.exe'");

var connectionString = config.GetValue<string>("AzureWebJobsServiceBus") ?? config.GetValue<string>("Values:AzureWebJobsServiceBus");
Assert.IsNotNull(connectionString, "Environment variable 'AzureWebJobsServiceBus' should be defined to run tests.");

var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(60));
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceBus.Tests/ServiceBus.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NServiceBus" Version="8.0.3" />
<PackageReference Include="NServiceBus" Version="8.1.1" />
<PackageReference Include="Particular.Approvals" Version="0.4.1" />
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Testing.Handlers/Testing.Handlers.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NServiceBus" Version="8.0.3" />
<PackageReference Include="NServiceBus" Version="8.1.1" />
</ItemGroup>

</Project>