Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit afeac8a

Browse files
authored
Merge branch 'main' into rust-1.71.1
2 parents ed0ec59 + 020c4d5 commit afeac8a

File tree

16 files changed

+890
-1042
lines changed

16 files changed

+890
-1042
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ concurrency:
1616

1717
env:
1818
CARGO_TERM_COLOR: always
19-
ACTIONS_CACHE_KEY_DATE: 2023-06-19
19+
ACTIONS_CACHE_KEY_DATE: 2023-08-10
2020
CI: true
2121

2222
jobs:

src/ApiService/CSharpExtensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationOptions",
99
"Microsoft.Extensions.Configuration.IConfigurationBuilder",
1010
"Microsoft.Extensions.DependencyInjection.IServiceCollection",
11-
"Moq.Language.Flow.IReturnsResult",
11+
"NSubstitute.Core.ConfiguredCall",
1212
"System.Text.StringBuilder"
1313
]
1414
}

src/ApiService/IntegrationTests/Fakes/TestHttpRequestData.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using Microsoft.Azure.Functions.Worker;
88
using Microsoft.Azure.Functions.Worker.Http;
99
using Microsoft.Extensions.Options;
10-
using Moq;
10+
using NSubstitute;
1111

1212
namespace IntegrationTests.Fakes;
1313

@@ -35,10 +35,10 @@ sealed class TestOptions : IOptions<WorkerOptions> {
3535

3636
private static FunctionContext NewFunctionContext() {
3737
// mocking this out at the moment since there’s no way to create a subclass
38-
var mock = new Mock<FunctionContext>();
38+
var functionContext = Substitute.For<FunctionContext>();
3939
var services = new TestServices();
40-
mock.SetupGet(fc => fc.InstanceServices).Returns(services);
41-
return mock.Object;
40+
functionContext.InstanceServices.Returns(services);
41+
return functionContext;
4242
}
4343

4444
public static TestHttpRequestData FromJson<T>(string method, T obj)

src/ApiService/IntegrationTests/IntegrationTests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<PrivateAssets>all</PrivateAssets>
1212
</PackageReference>
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
14-
<PackageReference Include="Moq" Version="4.18.4" />
1514
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="7.0.2" />
1615
<PackageReference Include="xunit" Version="2.5.0" />
1716
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">

src/ApiService/IntegrationTests/packages.lock.json

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@
3333
"Microsoft.TestPlatform.TestHost": "17.6.2"
3434
}
3535
},
36-
"Moq": {
37-
"type": "Direct",
38-
"requested": "[4.18.4, )",
39-
"resolved": "4.18.4",
40-
"contentHash": "IOo+W51+7Afnb0noltJrKxPBSfsgMzTKCw+Re5AMx8l/vBbAbMDOynLik4+lBYIWDJSO0uV7Zdqt7cNb6RZZ+A==",
41-
"dependencies": {
42-
"Castle.Core": "5.1.1"
43-
}
44-
},
4536
"System.Security.Cryptography.Pkcs": {
4637
"type": "Direct",
4738
"requested": "[7.0.2, )",
@@ -225,8 +216,8 @@
225216
},
226217
"Castle.Core": {
227218
"type": "Transitive",
228-
"resolved": "5.1.1",
229-
"contentHash": "rpYtIczkzGpf+EkZgDr9CClTdemhsrwA/W5hMoPjLkRFnXzH44zDLoovXeKtmxb1ykXK9aJVODSpiJml8CTw2g==",
219+
"resolved": "5.0.0",
220+
"contentHash": "edc8jjyXqzzy8jFdhs36FZdwmlDDTgqPb2Zy1Q5F/f2uAc88bu/VS/0Tpvgupmpl9zJOvOo5ZizVANb0ltN1NQ==",
230221
"dependencies": {
231222
"System.Diagnostics.EventLog": "6.0.0"
232223
}
@@ -1240,6 +1231,14 @@
12401231
"Newtonsoft.Json": "10.0.1"
12411232
}
12421233
},
1234+
"NSubstitute": {
1235+
"type": "Transitive",
1236+
"resolved": "5.0.0",
1237+
"contentHash": "CWGy4oXvcJcZzL7m5Rr/eMSejFXMDq1RRMlsbL6eltS3AuN/d8GH3ZzUcuStQcCSlcx+hpsgTxdnb3lhozWG6w==",
1238+
"dependencies": {
1239+
"Castle.Core": "5.0.0"
1240+
}
1241+
},
12431242
"NuGet.Frameworks": {
12441243
"type": "Transitive",
12451244
"resolved": "6.5.0",
@@ -2563,7 +2562,7 @@
25632562
"FsCheck": "[2.16.5, )",
25642563
"FsCheck.Xunit": "[2.16.5, )",
25652564
"Microsoft.NET.Test.Sdk": "[17.6.2, )",
2566-
"Moq": "[4.18.4, )",
2565+
"NSubstitute": "[5.0.0, )",
25672566
"System.Security.Cryptography.Pkcs": "[7.0.2, )",
25682567
"xunit": "[2.5.0, )"
25692568
}

src/ApiService/Tests/OrmTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using FluentAssertions;
1111
using Microsoft.OneFuzz.Service;
1212
using Microsoft.OneFuzz.Service.OneFuzzLib.Orm;
13-
using Moq;
1413
using Xunit;
1514
using Task = System.Threading.Tasks.Task;
1615

src/ApiService/Tests/Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageReference Include="FsCheck" Version="2.16.5" />
1313
<PackageReference Include="FsCheck.Xunit" Version="2.16.5" />
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
15-
<PackageReference Include="Moq" Version="4.18.4" />
15+
<PackageReference Include="NSubstitute" Version="5.0.0" />
1616
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="7.0.2" />
1717
<PackageReference Include="xunit" Version="2.5.0" />
1818
<PackageReference Include="FluentAssertions" Version="6.11.0" />

src/ApiService/Tests/TimerReproTests.cs

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,76 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using Microsoft.Azure.Functions.Worker;
54
using Microsoft.Extensions.Logging;
65
using Microsoft.OneFuzz.Service;
76
using Microsoft.OneFuzz.Service.Functions;
8-
using Moq;
7+
using NSubstitute;
98
using Xunit;
109
namespace Tests;
1110

1211
public class TimerReproTests {
1312
private readonly ILogger<TimerRepro> _log;
14-
private readonly Mock<IOnefuzzContext> _mockCtx;
15-
private readonly Mock<IReproOperations> _mockReproOperations;
13+
private readonly IOnefuzzContext _mockCtx;
14+
private readonly IReproOperations _mockReproOperations;
1615

1716
public TimerReproTests() {
18-
_mockCtx = new Mock<IOnefuzzContext>();
1917

20-
_mockReproOperations = new Mock<IReproOperations>();
18+
_mockReproOperations = Substitute.For<IReproOperations>();
19+
_mockReproOperations.SearchExpired().Returns(AsyncEnumerable.Empty<Repro>());
20+
_mockReproOperations.SearchStates(VmStateHelper.NeedsWork).Returns(AsyncEnumerable.Empty<Repro>());
2121

22-
_mockReproOperations.Setup(x => x.SearchExpired())
23-
.Returns(AsyncEnumerable.Empty<Repro>());
24-
_mockReproOperations.Setup(x => x.SearchStates(VmStateHelper.NeedsWork))
25-
.Returns(AsyncEnumerable.Empty<Repro>());
22+
_mockCtx = Substitute.For<IOnefuzzContext>();
23+
_mockCtx.ReproOperations.Returns(_mockReproOperations);
2624

27-
_log = new Mock<ILogger<TimerRepro>>().Object;
25+
_log = Substitute.For<ILogger<TimerRepro>>();
2826
}
2927

3028
[Fact]
3129
public async System.Threading.Tasks.Task NoExpiredRepros() {
32-
_mockReproOperations.Setup(x => x.SearchExpired())
33-
.Returns(AsyncEnumerable.Empty<Repro>());
34-
35-
_mockCtx.Setup(x => x.ReproOperations)
36-
.Returns(_mockReproOperations.Object);
3730

38-
var timerRepro = new TimerRepro(_log, _mockCtx.Object);
31+
var timerRepro = new TimerRepro(_log, _mockCtx);
3932
await timerRepro.Run(new TimerInfo());
4033

41-
_mockReproOperations.Verify(x => x.Stopping(It.IsAny<Repro>()), Times.Never());
34+
_ = await _mockReproOperations.DidNotReceive().Stopping(Arg.Any<Repro>());
4235
}
4336

4437
[Fact]
4538
public async System.Threading.Tasks.Task ExpiredRepro() {
46-
_mockReproOperations.Setup(x => x.SearchExpired())
47-
.Returns(new List<Repro> {
48-
GenerateRepro()
49-
}.ToAsyncEnumerable());
39+
_mockReproOperations.SearchExpired()
40+
.Returns(new[] { GenerateRepro() }.ToAsyncEnumerable());
5041

51-
_mockCtx.Setup(x => x.ReproOperations)
52-
.Returns(_mockReproOperations.Object);
53-
54-
var timerRepro = new TimerRepro(_log, _mockCtx.Object);
42+
var timerRepro = new TimerRepro(_log, _mockCtx);
5543
await timerRepro.Run(new TimerInfo());
5644

57-
_mockReproOperations.Verify(x => x.Stopping(It.IsAny<Repro>()), Times.Once());
45+
_ = await _mockReproOperations.Received().Stopping(Arg.Any<Repro>());
5846
}
5947

6048
[Fact]
6149
public async System.Threading.Tasks.Task NoNeedsWorkRepros() {
62-
_mockReproOperations.Setup(x => x.SearchStates(VmStateHelper.NeedsWork))
50+
_mockReproOperations.SearchStates(VmStateHelper.NeedsWork)
6351
.Returns(AsyncEnumerable.Empty<Repro>());
6452

65-
_mockCtx.Setup(x => x.ReproOperations)
66-
.Returns(_mockReproOperations.Object);
67-
68-
var timerRepro = new TimerRepro(_log, _mockCtx.Object);
53+
var timerRepro = new TimerRepro(_log, _mockCtx);
6954
await timerRepro.Run(new TimerInfo());
7055

71-
_mockReproOperations.Verify(x => x.ProcessStateUpdates(It.IsAny<Repro>(), It.IsAny<int>()), Times.Never());
56+
_ = await _mockReproOperations.DidNotReceive().ProcessStateUpdates(Arg.Any<Repro>(), Arg.Any<int>());
7257
}
7358

7459
[Fact]
7560
public async System.Threading.Tasks.Task DontProcessExpiredVms() {
7661
var expiredVm = GenerateRepro();
7762
var notExpiredVm = GenerateRepro();
7863

79-
_mockReproOperations.Setup(x => x.SearchExpired())
80-
.Returns(new List<Repro> {
81-
expiredVm
82-
}.ToAsyncEnumerable());
83-
84-
_mockReproOperations.Setup(x => x.SearchStates(VmStateHelper.NeedsWork))
85-
.Returns(new List<Repro> {
86-
expiredVm,
87-
notExpiredVm
88-
}.ToAsyncEnumerable());
64+
_mockReproOperations.SearchExpired()
65+
.Returns(new[] { expiredVm }.ToAsyncEnumerable());
8966

90-
_mockCtx.Setup(x => x.ReproOperations)
91-
.Returns(_mockReproOperations.Object);
67+
_mockReproOperations.SearchStates(VmStateHelper.NeedsWork)
68+
.Returns(new[] { expiredVm, notExpiredVm }.ToAsyncEnumerable());
9269

93-
var timerRepro = new TimerRepro(_log, _mockCtx.Object);
70+
var timerRepro = new TimerRepro(_log, _mockCtx);
9471
await timerRepro.Run(new TimerInfo());
9572

96-
_mockReproOperations.Verify(x => x.ProcessStateUpdates(It.IsAny<Repro>(), It.IsAny<int>()), Times.Once());
73+
_ = await _mockReproOperations.Received().ProcessStateUpdates(Arg.Any<Repro>(), Arg.Any<int>());
9774
}
9875

9976
private static Repro GenerateRepro() {

src/ApiService/Tests/packages.lock.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
"Microsoft.TestPlatform.TestHost": "17.6.2"
5353
}
5454
},
55-
"Moq": {
55+
"NSubstitute": {
5656
"type": "Direct",
57-
"requested": "[4.18.4, )",
58-
"resolved": "4.18.4",
59-
"contentHash": "IOo+W51+7Afnb0noltJrKxPBSfsgMzTKCw+Re5AMx8l/vBbAbMDOynLik4+lBYIWDJSO0uV7Zdqt7cNb6RZZ+A==",
57+
"requested": "[5.0.0, )",
58+
"resolved": "5.0.0",
59+
"contentHash": "CWGy4oXvcJcZzL7m5Rr/eMSejFXMDq1RRMlsbL6eltS3AuN/d8GH3ZzUcuStQcCSlcx+hpsgTxdnb3lhozWG6w==",
6060
"dependencies": {
61-
"Castle.Core": "5.1.1"
61+
"Castle.Core": "5.0.0"
6262
}
6363
},
6464
"System.Security.Cryptography.Pkcs": {
@@ -244,8 +244,8 @@
244244
},
245245
"Castle.Core": {
246246
"type": "Transitive",
247-
"resolved": "5.1.1",
248-
"contentHash": "rpYtIczkzGpf+EkZgDr9CClTdemhsrwA/W5hMoPjLkRFnXzH44zDLoovXeKtmxb1ykXK9aJVODSpiJml8CTw2g==",
247+
"resolved": "5.0.0",
248+
"contentHash": "edc8jjyXqzzy8jFdhs36FZdwmlDDTgqPb2Zy1Q5F/f2uAc88bu/VS/0Tpvgupmpl9zJOvOo5ZizVANb0ltN1NQ==",
249249
"dependencies": {
250250
"System.Diagnostics.EventLog": "6.0.0"
251251
}

0 commit comments

Comments
 (0)