Skip to content

Commit

Permalink
[Refactor] Replace Moq with NSubstitute for Mocking in GuildHelperTes…
Browse files Browse the repository at this point in the history
…ts (#2754)

* [Refactor] Replace Moq with NSubstitute for Mocking in GuildHelperTests

* [Refactor] Remove Redundant Assignment of 'output' Parameter

---------

Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com>
  • Loading branch information
DeclanFrampton and quinchs committed Nov 18, 2023
1 parent 9fd5c6c commit b988a18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/Discord.Net.Tests.Unit/Discord.Net.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="NSubstitute" Version="5.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
9 changes: 5 additions & 4 deletions test/Discord.Net.Tests.Unit/GuildHelperTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Discord.Rest;
using FluentAssertions;
using Moq;
using NSubstitute;
using System;
using Xunit;

Expand All @@ -15,11 +14,13 @@ public class GuildHelperTests
[InlineData(PremiumTier.Tier3, 100)]
public void GetUploadLimit(PremiumTier tier, ulong factor)
{
var guild = Mock.Of<IGuild>(g => g.PremiumTier == tier);
var guild = Substitute.For<IGuild>();
guild.PremiumTier.Returns(tier);

var expected = factor * (ulong)Math.Pow(2, 20);

var actual = GuildHelper.GetUploadLimit(guild);

actual.Should().Be(expected);
Assert.Equal(expected, actual);
}
}

0 comments on commit b988a18

Please sign in to comment.