Skip to content

Commit 6342c08

Browse files
committed
addressing stylecop warnings
1 parent 4f2d5bf commit 6342c08

25 files changed

+165
-140
lines changed

build/Settings.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.IO;
33
using System.Runtime.CompilerServices;
44

@@ -41,7 +41,7 @@ private static string config(string @default = null, [CallerMemberName] string k
4141

4242
public static readonly string NewTestProjectFile = Path.Combine("..", "test", "Cli", "Func.E2ETests", "Func.E2ETests.csproj");
4343

44-
public static readonly string RuntimeSettings = Path.Combine("..", "test", "Cli", "Func.E2ETests", "Func.E2ETests.csproj", "Runsettings", "StartTests_dotnet_inproc.runsettings"));
44+
public static readonly string RuntimeSettings = Path.Combine("..", "test", "Cli", "Func.E2ETests", "Func.E2ETests.csproj", "Runsettings", "StartTests_dotnet_inproc.runsettings");
4545

4646
public static readonly string[] TargetRuntimes = new[] {
4747
"min.win-arm64",

test/Cli/Func.E2ETests/BaseE2ETests.cs

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using Func.TestFramework.Helpers;
54
using System.Runtime.InteropServices;
6-
using Xunit.Abstractions;
5+
using Func.TestFramework.Helpers;
76
using Xunit;
7+
using Xunit.Abstractions;
88

99
namespace Func.E2ETests.Commands.FuncStart
1010
{
11-
public abstract class BaseE2ETest : IAsyncLifetime
11+
public abstract class BaseE2ETests(ITestOutputHelper log) : IAsyncLifetime
1212
{
13-
protected ITestOutputHelper Log { get; }
14-
protected string FuncPath { get; set; }
13+
protected ITestOutputHelper Log { get; } = log;
1514

16-
protected string WorkingDirectory { get; set; } = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
15+
protected string? FuncPath { get; set; } = Environment.GetEnvironmentVariable(Constants.FuncPath);
1716

18-
protected BaseE2ETest(ITestOutputHelper log)
19-
{
20-
Log = log;
21-
FuncPath = Environment.GetEnvironmentVariable(Constants.FuncPath);
22-
}
17+
protected string WorkingDirectory { get; set; } = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
2318

2419
public Task InitializeAsync()
2520
{
26-
if (FuncPath == null)
21+
if (FuncPath is null)
2722
{
2823
// Fallback for local testing in Visual Studio, etc.
2924
FuncPath = Path.Combine(Environment.CurrentDirectory, "func");
@@ -53,6 +48,7 @@ public Task DisposeAsync()
5348
{
5449
// Cleanup failed but we shouldn't crash on this
5550
}
51+
5652
return Task.CompletedTask;
5753
}
5854

@@ -61,7 +57,7 @@ public async Task FuncInitWithRetryAsync(string testName, IEnumerable<string> ar
6157
await FunctionAppSetupHelper.FuncInitWithRetryAsync(FuncPath, testName, WorkingDirectory, Log, args);
6258
}
6359

64-
public async Task FuncNewWithRetryAsync(string testName, IEnumerable<string> args, string workerRuntime = null)
60+
public async Task FuncNewWithRetryAsync(string testName, IEnumerable<string> args, string? workerRuntime = null)
6561
{
6662
await FunctionAppSetupHelper.FuncNewWithRetryAsync(FuncPath, testName, WorkingDirectory, Log, args, workerRuntime);
6763
}

test/Cli/Func.E2ETests/Commands/FuncStart/AuthTests.cs

+8-10
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
using Func.TestFramework.Assertions;
66
using Func.TestFramework.Commands;
77
using Func.TestFramework.Helpers;
8-
using Xunit.Abstractions;
98
using Xunit;
9+
using Xunit.Abstractions;
1010

1111
namespace Func.E2ETests.Commands.FuncStart
1212
{
13-
public class AuthTests : BaseE2ETest
13+
public class AuthTests : BaseE2ETests
1414
{
15-
public AuthTests(ITestOutputHelper log) : base(log)
15+
public AuthTests(ITestOutputHelper log)
16+
: base(log)
1617
{
1718
}
1819

1920
[Theory]
20-
[InlineData("function", false, "Welcome to Azure Functions!", "response from default function should be 'Welcome to Azure Functions!'")]
21-
[InlineData("function", true, "", "the call to the function is unauthorized")]
22-
[InlineData("anonymous", true, "Welcome to Azure Functions!", "response from default function should be 'Welcome to Azure Functions!'")]
21+
[InlineData("function", false, "Welcome to Azure Functions!")]
22+
[InlineData("function", true, "")]
23+
[InlineData("anonymous", true, "Welcome to Azure Functions!")]
2324
public async Task Start_DotnetIsolated_Test_EnableAuthFeature(
2425
string authLevel,
2526
bool enableAuth,
26-
string expectedResult,
27-
string becauseReason)
27+
string expectedResult)
2828
{
2929
int port = ProcessHelper.GetAvailablePort();
3030

@@ -35,8 +35,6 @@ public async Task Start_DotnetIsolated_Test_EnableAuthFeature(
3535
await FuncInitWithRetryAsync(uniqueTestName, new[] { ".", "--worker-runtime", "dotnet-isolated" });
3636
await FuncNewWithRetryAsync(uniqueTestName, new[] { ".", "--template", "Httptrigger", "--name", "HttpTrigger", "--authlevel", authLevel });
3737

38-
string capturedContent = null;
39-
4038
// Call func start
4139
var funcStartCommand = new FuncStartCommand(FuncPath, methodName, Log);
4240
funcStartCommand.ProcessStartedHandler = async (process) =>

test/Cli/Func.E2ETests/Commands/FuncStart/InProcTests.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
using Func.TestFramework.Assertions;
77
using Func.TestFramework.Commands;
88
using Func.TestFramework.Helpers;
9-
using Xunit.Abstractions;
109
using Xunit;
10+
using Xunit.Abstractions;
1111

1212
namespace Func.E2ETests.Commands.FuncStart
1313
{
1414
[Trait(TestTraits.Group, TestTraits.InProc)]
15-
public class InProcTests : BaseE2ETest
15+
public class InProcTests : BaseE2ETests
1616
{
17-
public InProcTests(ITestOutputHelper log) : base(log)
17+
public InProcTests(ITestOutputHelper log)
18+
: base(log)
1819
{
1920
}
2021

@@ -116,4 +117,4 @@ public async Task Start_InProc_LogLevelOverridenWithFilter_LogLevelSetToExpected
116117
result.Should().NotHaveStdOutContaining("Reading host configuration file");
117118
}
118119
}
119-
}
120+
}

test/Cli/Func.E2ETests/Commands/FuncStart/LogLevelTests.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using FluentAssertions;
5+
using Func.E2ETests.Commands.FuncStart;
56
using Func.TestFramework.Assertions;
67
using Func.TestFramework.Commands;
78
using Func.TestFramework.Helpers;
8-
using Xunit.Abstractions;
99
using Xunit;
10+
using Xunit.Abstractions;
1011

11-
namespace Func.E2ETests.func_start.Tests
12+
namespace Func.E2ETests.Commands.FuncStart
1213
{
13-
public class LogLevelTests : BaseE2ETest
14+
public class LogLevelTests : BaseE2ETests
1415
{
15-
public LogLevelTests(ITestOutputHelper log) : base(log)
16+
public LogLevelTests(ITestOutputHelper log)
17+
: base(log)
1618
{
1719
}
1820

@@ -82,4 +84,4 @@ public async Task Start_LanguageWorker_LogLevelOverridenViaHostJson_LogLevelSetT
8284
result.Should().NotHaveStdOutContaining("Initializing function HTTP routes");
8385
}
8486
}
85-
}
87+
}

test/Cli/Func.E2ETests/Commands/FuncStart/MissingConfigTests.cs

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
using Func.TestFramework.Assertions;
77
using Func.TestFramework.Commands;
88
using Func.TestFramework.Helpers;
9-
using Xunit.Abstractions;
109
using Xunit;
10+
using Xunit.Abstractions;
1111

1212
namespace Func.E2ETests.Commands.FuncStart
1313
{
14-
public class MissingConfigTests : BaseE2ETest
14+
public class MissingConfigTests : BaseE2ETests
1515
{
16-
public MissingConfigTests(ITestOutputHelper log) : base(log)
16+
public MissingConfigTests(ITestOutputHelper log)
17+
: base(log)
1718
{
1819
}
1920

@@ -93,6 +94,7 @@ public async Task Start_MissingLocalSettingsJson_BehavesAsExpected(string langua
9394
var funcNewArgs = new[] { ".", "--template", "HttpTrigger", "--name", "HttpTriggerFunc" }
9495
.Concat(!language.Contains("dotnet") ? new[] { "--language", language } : Array.Empty<string>())
9596
.ToArray();
97+
9698
// Add HTTP trigger using retry helper
9799
await FuncNewWithRetryAsync(logFileName, funcNewArgs);
98100

@@ -123,6 +125,7 @@ public async Task Start_MissingLocalSettingsJson_BehavesAsExpected(string langua
123125
{
124126
result.Should().HaveStdOutContaining("HttpTriggerFunc: [GET,POST] http://localhost:");
125127
}
128+
126129
result.Should().HaveStdOutContaining("Executed 'Functions.HttpTriggerFunc' (Succeeded");
127130
}
128131
finally
@@ -192,7 +195,7 @@ public async Task Start_EmptyEnvVars_HandledAsExpected()
192195
// Modify settings file to have empty value
193196
string settingsPath = Path.Combine(WorkingDirectory, "local.settings.json");
194197
string settingsContent = File.ReadAllText(settingsPath);
195-
settingsContent = settingsContent.Replace("EMPTY_VALUE", "");
198+
settingsContent = settingsContent.Replace("EMPTY_VALUE", string.Empty);
196199
File.WriteAllText(settingsPath, settingsContent);
197200

198201
// Call func start
@@ -212,4 +215,4 @@ public async Task Start_EmptyEnvVars_HandledAsExpected()
212215
result.Should().NotHaveStdOutContaining("Skipping 'emptySetting' from local settings as it's already defined in current environment variables.");
213216
}
214217
}
215-
}
218+
}

test/Cli/Func.E2ETests/Commands/FuncStart/MultipleFunctionsTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Func.E2ETests.Commands.FuncStart
1313
{
14-
public class MultipleFunctionsTests : BaseE2ETest
14+
public class MultipleFunctionsTests : BaseE2ETests
1515
{
1616
public MultipleFunctionsTests(ITestOutputHelper log) : base(log)
1717
{

test/Cli/Func.E2ETests/Commands/FuncStart/TestsWithFixtures/DotnetInProc6Tests.cs

+15-15
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,32 @@
77
using Func.TestFramework.Assertions;
88
using Func.TestFramework.Commands;
99
using Func.TestFramework.Helpers;
10-
using Xunit.Abstractions;
1110
using Xunit;
11+
using Xunit.Abstractions;
1212

1313
namespace Func.E2ETests.Commands.FuncStart.TestsWithFixtures
1414
{
15-
[Collection("Dotnet6InProc")]
15+
[Collection("DotnetInProc6")]
1616
[Trait(TestTraits.Group, TestTraits.InProc)]
17-
public class Dotnet6InProcTests : IClassFixture<Dotnet6InProcFunctionAppFixture>
17+
public class DotnetInProc6Tests : IClassFixture<Dotnet6InProcFunctionAppFixture>
1818
{
1919
private readonly Dotnet6InProcFunctionAppFixture _fixture;
2020

21-
public Dotnet6InProcTests(Dotnet6InProcFunctionAppFixture fixture, ITestOutputHelper log)
21+
public DotnetInProc6Tests(Dotnet6InProcFunctionAppFixture fixture, ITestOutputHelper log)
2222
{
2323
_fixture = fixture;
2424
_fixture.Log = log;
2525
}
2626

2727
[Fact]
2828
[Trait(TestTraits.Group, TestTraits.RequiresNestedInProcArtifacts)]
29-
public async Task Start_InProc_Net6_SuccessfulFunctionExecution_WithSpecifyingRuntime()
29+
public void Start_InProc_Net6_SuccessfulFunctionExecution_WithSpecifyingRuntime()
3030
{
3131
int port = ProcessHelper.GetAvailablePort();
3232

3333
// Call func start
3434
var funcStartCommand = new FuncStartCommand(_fixture.FuncPath, "Start_InProc_Net6_SuccessfulFunctionExecution_WithSpecifyingRuntime", _fixture.Log);
35-
string capturedContent = null;
35+
string? capturedContent = null;
3636

3737
funcStartCommand.ProcessStartedHandler = async (process) =>
3838
{
@@ -53,14 +53,14 @@ public async Task Start_InProc_Net6_SuccessfulFunctionExecution_WithSpecifyingRu
5353

5454
[Fact]
5555
[Trait(TestTraits.Group, TestTraits.RequiresNestedInProcArtifacts)]
56-
public async Task Start_InProc_Net6_SuccessfulFunctionExecution_WithoutSpecifyingRuntime()
56+
public void Start_InProc_Net6_SuccessfulFunctionExecution_WithoutSpecifyingRuntime()
5757
{
5858
int port = ProcessHelper.GetAvailablePort();
5959

6060
// Call func start
6161
var funcStartCommand = new FuncStartCommand(_fixture.FuncPath, "Start_InProc_Net6_SuccessfulFunctionExecution_WithoutSpecifyingRuntime", _fixture.Log);
6262

63-
string capturedContent = null;
63+
string? capturedContent = null;
6464

6565
funcStartCommand.ProcessStartedHandler = async (process) =>
6666
{
@@ -80,7 +80,7 @@ public async Task Start_InProc_Net6_SuccessfulFunctionExecution_WithoutSpecifyin
8080
}
8181

8282
[Fact]
83-
public async Task Start_InProc_Dotnet6_WithoutSpecifyingRuntime_ExpectedToFail()
83+
public void Start_InProc_Dotnet6_WithoutSpecifyingRuntime_ExpectedToFail()
8484
{
8585
int port = ProcessHelper.GetAvailablePort();
8686

@@ -96,7 +96,7 @@ public async Task Start_InProc_Dotnet6_WithoutSpecifyingRuntime_ExpectedToFail()
9696
}
9797

9898
[Fact]
99-
public async Task Start_InProc_Dotnet6_WithSpecifyingRuntime_ExpectedToFail()
99+
public void Start_InProc_Dotnet6_WithSpecifyingRuntime_ExpectedToFail()
100100
{
101101
int port = ProcessHelper.GetAvailablePort();
102102

@@ -112,7 +112,7 @@ public async Task Start_InProc_Dotnet6_WithSpecifyingRuntime_ExpectedToFail()
112112
}
113113

114114
[Fact]
115-
public async Task DontStart_InProc8_SpecifiedRuntime_ForDotnet6InProc()
115+
public void DontStart_InProc8_SpecifiedRuntime_ForDotnet6InProc()
116116
{
117117
int port = ProcessHelper.GetAvailablePort();
118118

@@ -128,7 +128,7 @@ public async Task DontStart_InProc8_SpecifiedRuntime_ForDotnet6InProc()
128128
}
129129

130130
[Fact]
131-
public async Task DontStart_DefaultRuntime_SpecifiedRuntime_ForDotnet6InProc()
131+
public void DontStart_DefaultRuntime_SpecifiedRuntime_ForDotnet6InProc()
132132
{
133133
int port = ProcessHelper.GetAvailablePort();
134134

@@ -145,7 +145,7 @@ public async Task DontStart_DefaultRuntime_SpecifiedRuntime_ForDotnet6InProc()
145145

146146
[Fact]
147147
[Trait(TestTraits.Group, TestTraits.RequiresNestedInProcArtifacts)]
148-
public async Task Start_InProc_InvalidHostJson_FailsWithExpectedError()
148+
public void Start_InProc_InvalidHostJson_FailsWithExpectedError()
149149
{
150150
int port = ProcessHelper.GetAvailablePort();
151151

@@ -177,7 +177,7 @@ public async Task Start_InProc_InvalidHostJson_FailsWithExpectedError()
177177

178178
[Fact]
179179
[Trait(TestTraits.Group, TestTraits.RequiresNestedInProcArtifacts)]
180-
public async Task Start_InProc_MissingHostJson_FailsWithExpectedError()
180+
public void Start_InProc_MissingHostJson_FailsWithExpectedError()
181181
{
182182
int port = ProcessHelper.GetAvailablePort();
183183

@@ -202,4 +202,4 @@ public async Task Start_InProc_MissingHostJson_FailsWithExpectedError()
202202
Directory.Delete(tempDir, true);
203203
}
204204
}
205-
}
205+
}

0 commit comments

Comments
 (0)