1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-17 00:03:17 -05:00

Fixed tests.

This commit is contained in:
Todd Martin 2025-06-13 18:03:01 -04:00
parent a8a04102a6
commit 145c969d8b
No known key found for this signature in database
GPG Key ID: 663E7AF5C839BC8F
2 changed files with 7 additions and 6 deletions

View File

@ -12,9 +12,9 @@ namespace Bit.Core.Auth.Services;
public class TwoFactorEmailService : ITwoFactorEmailService public class TwoFactorEmailService : ITwoFactorEmailService
{ {
private ICurrentContext _currentContext; private readonly ICurrentContext _currentContext;
private UserManager<User> _userManager; private readonly UserManager<User> _userManager;
private IMailService _mailService; private readonly IMailService _mailService;
public TwoFactorEmailService( public TwoFactorEmailService(
ICurrentContext currentContext, ICurrentContext currentContext,

View File

@ -18,6 +18,7 @@ namespace Bit.Core.Test.Auth.Services;
[SutProviderCustomize] [SutProviderCustomize]
public class TwoFactorEmailServiceTests public class TwoFactorEmailServiceTests
{ {
[Theory, BitAutoData] [Theory, BitAutoData]
public async Task SendTwoFactorEmailAsync_Success(SutProvider<TwoFactorEmailService> sutProvider, User user) public async Task SendTwoFactorEmailAsync_Success(SutProvider<TwoFactorEmailService> sutProvider, User user)
{ {
@ -34,7 +35,7 @@ public class TwoFactorEmailServiceTests
.GenerateAsync("TwoFactor", Arg.Any<UserManager<User>>(), user) .GenerateAsync("TwoFactor", Arg.Any<UserManager<User>>(), user)
.Returns(Task.FromResult(token)); .Returns(Task.FromResult(token));
var context = sutProvider.GetDependency<ICurrentContext>(); var context = Substitute.For<ICurrentContext>();
context.DeviceType = DeviceType.Android; context.DeviceType = DeviceType.Android;
context.IpAddress = IpAddress; context.IpAddress = IpAddress;
@ -109,7 +110,7 @@ public class TwoFactorEmailServiceTests
{ {
var sutProvider = new SutProvider<TwoFactorEmailService>(); var sutProvider = new SutProvider<TwoFactorEmailService>();
var context = sutProvider.GetDependency<ICurrentContext>(); var context = Substitute.For<ICurrentContext>();
context.DeviceType = deviceType; context.DeviceType = deviceType;
context.IpAddress = "1.1.1.1"; context.IpAddress = "1.1.1.1";
@ -125,7 +126,7 @@ public class TwoFactorEmailServiceTests
{ {
var sutProvider = new SutProvider<TwoFactorEmailService>(); var sutProvider = new SutProvider<TwoFactorEmailService>();
var context = sutProvider.GetDependency<ICurrentContext>(); var context = Substitute.For<ICurrentContext>();
context.DeviceType = null; context.DeviceType = null;
context.IpAddress = "1.1.1.1"; context.IpAddress = "1.1.1.1";