Skip to content

Commit

Permalink
Merge branch 'main' into release/4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Aug 9, 2023
2 parents 8d7ca6e + a0b07ed commit b977b7a
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 40 deletions.
17 changes: 14 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- X10D: `DateTime.Age(DateTime)` and `DateTimeOffset.Age(DateTimeOffset)` parameter renamed from `asOf` to `referenceDate`.
- X10D: DateTime.Age(DateTime) and DateTimeOffset.Age(DateTimeOffset) parameter renamed from asOf to referenceDate.

### Removed

- X10D: Removed `IEnumerable<T>.ConcatOne` - this functionality already exists with `Append`.
- X10D: Removed `IEnumerable<T>.ConcatOne` - this functionality already exists with `Append`.

## [3.2.2] - 2023-06-05

### Added

- X10D.DSharpPlus: Added support for new usernames. See https://discord.com/blog/usernames

## 3.2.1 - 2023-06-05

ERRONEOUS RELEASE.

## [3.2.0] - 2023-04-03

Expand Down Expand Up @@ -597,7 +607,8 @@ please [open an issue](https://github.com/oliverbooth/X10D/issues)!

Earlier versions of this package are undocumented and unlisted from package results.

[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.2.0...main
[unreleased]: https://github.com/oliverbooth/X10D/compare/v3.2.2...main
[3.2.2]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.2
[3.2.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.2.0
[3.1.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.1.0
[3.0.0]: https://github.com/oliverbooth/X10D/releases/tag/v3.0.0
Expand Down
6 changes: 6 additions & 0 deletions X10D.DSharpPlus/src/DiscordUserExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public static string GetUsernameWithDiscriminator(this DiscordUser user)
throw new ArgumentNullException(nameof(user));
}

if (user.Discriminator == "0")
{
// user has a new username. see: https://discord.com/blog/usernames
return user.Username;
}

return $"{user.Username}#{user.Discriminator}";
}

Expand Down
2 changes: 1 addition & 1 deletion X10D.Tests/X10D.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
21 changes: 11 additions & 10 deletions X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.ObjectModel;
using Moq;
using NSubstitute;
using NUnit.Framework;
using X10D.Collections;

Expand All @@ -13,16 +13,17 @@ public class ClearAndDisposeAllTests
[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);
}

Expand All @@ -36,8 +37,8 @@ public void ClearAndDisposeAll_ShouldThrowArgumentNullException_WhenCalledWithNu
[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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.ObjectModel;
using Moq;
using NSubstitute;
using NUnit.Framework;
using X10D.Collections;

Expand All @@ -13,16 +13,17 @@ public class ClearAndDisposeAllAsyncTests
[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);
}

Expand All @@ -36,8 +37,8 @@ public void ClearAndDisposeAllAsync_ShouldThrowArgumentNullException_WhenCalledW
[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);
}
Expand Down
16 changes: 8 additions & 8 deletions X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Moq;
using NSubstitute;
using NUnit.Framework;
using X10D.Collections;

Expand All @@ -12,16 +12,16 @@ public class DisposeAllTests
[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]
Expand Down
16 changes: 8 additions & 8 deletions X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Moq;
using NSubstitute;
using NUnit.Framework;
using X10D.Collections;

Expand All @@ -12,16 +12,16 @@ public class DisposeAllAsyncTests
[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]
Expand Down

0 comments on commit b977b7a

Please sign in to comment.