mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 12:08:48 +00:00
fix: replace Moq with a library that DOESN'T steal your pii
Moq has recently introduced a payload named SponsorLink which takes PII (your email address) to send to a third party server for remote verification. This kind of suspicious data harvesting is simply unacceptable, and the developers have now destroyed all credibility and trust with their user base. This change replaces Moq with NSubstitute. For further information, see: https://github.com/moq/moq/issues/1372
This commit is contained in:
parent
7b844bd703
commit
a0b07edc82
@ -17,7 +17,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1"/>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0"/>
|
||||
<PackageReference Include="Moq" Version="4.18.4"/>
|
||||
<PackageReference Include="NSubstitute" Version="5.0.0"/>
|
||||
<PackageReference Include="NUnit" Version="3.13.3"/>
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2"/>
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.6.1"/>
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Moq;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using X10D.Collections;
|
||||
|
||||
@ -13,16 +13,17 @@ public partial class CollectionTests
|
||||
[Test]
|
||||
public void ClearAndDisposeAll_ShouldClearAndDisposeAllItems_WhenCalledWithValidList()
|
||||
{
|
||||
var mock1 = new Mock<IDisposable>();
|
||||
var mock2 = new Mock<IDisposable>();
|
||||
var mock3 = new Mock<IDisposable>();
|
||||
var list = new List<IDisposable> {mock1.Object, mock2.Object, mock3.Object};
|
||||
var substitute1 = Substitute.For<IDisposable>();
|
||||
var substitute2 = Substitute.For<IDisposable>();
|
||||
var substitute3 = Substitute.For<IDisposable>();
|
||||
var list = new List<IDisposable> {substitute1, substitute2, substitute3};
|
||||
|
||||
list.ClearAndDisposeAll();
|
||||
|
||||
mock1.Verify(i => i.Dispose(), Times.Once);
|
||||
mock2.Verify(i => i.Dispose(), Times.Once);
|
||||
mock3.Verify(i => i.Dispose(), Times.Once);
|
||||
substitute1.Received(1).Dispose();
|
||||
substitute2.Received(1).Dispose();
|
||||
substitute3.Received(1).Dispose();
|
||||
|
||||
Assert.That(list, Is.Empty);
|
||||
}
|
||||
|
||||
@ -36,8 +37,8 @@ public partial class CollectionTests
|
||||
[Test]
|
||||
public void ClearAndDisposeAll_ShouldThrowInvalidOperationException_WhenCalledWithReadOnlyList()
|
||||
{
|
||||
var mock = new Mock<IDisposable>();
|
||||
var list = new ReadOnlyCollection<IDisposable>(new List<IDisposable> {mock.Object});
|
||||
var substitute = Substitute.For<IDisposable>();
|
||||
var list = new ReadOnlyCollection<IDisposable>(new List<IDisposable> {substitute});
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => list.ClearAndDisposeAll());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Moq;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using X10D.Collections;
|
||||
|
||||
@ -13,16 +13,17 @@ public partial class CollectionTests
|
||||
[Test]
|
||||
public async Task ClearAndDisposeAllAsync_ShouldClearAndDisposeAllItems_WhenCalledWithValidList()
|
||||
{
|
||||
var mock1 = new Mock<IAsyncDisposable>();
|
||||
var mock2 = new Mock<IAsyncDisposable>();
|
||||
var mock3 = new Mock<IAsyncDisposable>();
|
||||
var list = new List<IAsyncDisposable> {mock1.Object, mock2.Object, mock3.Object};
|
||||
var substitute1 = Substitute.For<IAsyncDisposable>();
|
||||
var substitute2 = Substitute.For<IAsyncDisposable>();
|
||||
var substitute3 = Substitute.For<IAsyncDisposable>();
|
||||
var list = new List<IAsyncDisposable> {substitute1, substitute2, substitute3};
|
||||
|
||||
await list.ClearAndDisposeAllAsync().ConfigureAwait(false);
|
||||
|
||||
mock1.Verify(i => i.DisposeAsync(), Times.Once);
|
||||
mock2.Verify(i => i.DisposeAsync(), Times.Once);
|
||||
mock3.Verify(i => i.DisposeAsync(), Times.Once);
|
||||
await substitute1.Received(1).DisposeAsync();
|
||||
await substitute2.Received(1).DisposeAsync();
|
||||
await substitute3.Received(1).DisposeAsync();
|
||||
|
||||
Assert.That(list, Is.Empty);
|
||||
}
|
||||
|
||||
@ -36,8 +37,8 @@ public partial class CollectionTests
|
||||
[Test]
|
||||
public void ClearAndDisposeAllAsync_ShouldThrowInvalidOperationException_WhenCalledWithReadOnlyList()
|
||||
{
|
||||
var mock = new Mock<IAsyncDisposable>();
|
||||
var list = new ReadOnlyCollection<IAsyncDisposable>(new List<IAsyncDisposable> {mock.Object});
|
||||
var substitute = Substitute.For<IAsyncDisposable>();
|
||||
var list = new ReadOnlyCollection<IAsyncDisposable>(new List<IAsyncDisposable> {substitute});
|
||||
|
||||
Assert.ThrowsAsync<InvalidOperationException>(list.ClearAndDisposeAllAsync);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Moq;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using X10D.Collections;
|
||||
|
||||
@ -12,16 +12,16 @@ public partial class EnumerableTests
|
||||
[Test]
|
||||
public void DisposeAll_ShouldDisposeAllItems_WhenCalledWithValidList()
|
||||
{
|
||||
var mock1 = new Mock<IDisposable>();
|
||||
var mock2 = new Mock<IDisposable>();
|
||||
var mock3 = new Mock<IDisposable>();
|
||||
var list = new List<IDisposable> {mock1.Object, mock2.Object, null!, mock3.Object};
|
||||
var substitute1 = Substitute.For<IDisposable>();
|
||||
var substitute2 = Substitute.For<IDisposable>();
|
||||
var substitute3 = Substitute.For<IDisposable>();
|
||||
var list = new List<IDisposable> { substitute1, substitute2, null!, substitute3 };
|
||||
|
||||
list.DisposeAll();
|
||||
|
||||
mock1.Verify(i => i.Dispose(), Times.Once);
|
||||
mock2.Verify(i => i.Dispose(), Times.Once);
|
||||
mock3.Verify(i => i.Dispose(), Times.Once);
|
||||
substitute1.Received(1).Dispose();
|
||||
substitute2.Received(1).Dispose();
|
||||
substitute3.Received(1).Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Moq;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using X10D.Collections;
|
||||
|
||||
@ -12,16 +12,16 @@ public partial class EnumerableTests
|
||||
[Test]
|
||||
public async Task DisposeAllAsync_ShouldDisposeAllItems_WhenCalledWithValidList()
|
||||
{
|
||||
var mock1 = new Mock<IAsyncDisposable>();
|
||||
var mock2 = new Mock<IAsyncDisposable>();
|
||||
var mock3 = new Mock<IAsyncDisposable>();
|
||||
var list = new List<IAsyncDisposable> {mock1.Object, mock2.Object, null!, mock3.Object};
|
||||
var substitute1 = Substitute.For<IAsyncDisposable>();
|
||||
var substitute2 = Substitute.For<IAsyncDisposable>();
|
||||
var substitute3 = Substitute.For<IAsyncDisposable>();
|
||||
var list = new List<IAsyncDisposable> { substitute1, substitute2, null!, substitute3 };
|
||||
|
||||
await list.DisposeAllAsync().ConfigureAwait(false);
|
||||
|
||||
mock1.Verify(i => i.DisposeAsync(), Times.Once);
|
||||
mock2.Verify(i => i.DisposeAsync(), Times.Once);
|
||||
mock3.Verify(i => i.DisposeAsync(), Times.Once);
|
||||
await substitute1.Received(1).DisposeAsync();
|
||||
await substitute2.Received(1).DisposeAsync();
|
||||
await substitute3.Received(1).DisposeAsync();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
Loading…
Reference in New Issue
Block a user