Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMi-Ha committed Mar 2, 2024
1 parent 99f83dc commit 43fafbc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions PWManager.UnitTests/Services/LoginServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class LoginServiceTest {
private ICryptService _cryptService = Substitute.For<ICryptService>();
private ISettingsRepository _settingsRepository = Substitute.For<ISettingsRepository>();
private DataContextWrapper _wrapper = Substitute.For<DataContextWrapper>();
private IApplicationEnvironment _env = Substitute.For<IApplicationEnvironment>();
private IUserEnvironment _userEnv = Substitute.For<IUserEnvironment>();
private ICryptEnvironment _cryptEnv = Substitute.For<ICryptEnvironment>();
private IUserRepository _userRepo = Substitute.For<IUserRepository>();

[Fact]
Expand All @@ -31,12 +32,12 @@ public void Login_Should_SetEnviroment() {
);
_groupRepo.GetGroup(Arg.Any<string>()).Returns(group);

_sut = new LoginService(_wrapper, _userRepo, _groupRepo, _cryptService, _settingsRepository, _env);
_sut = new LoginService(_wrapper, _userRepo, _groupRepo, _cryptService, _settingsRepository, _userEnv, _cryptEnv);
_sut.Login("TestUserName", "WhatAPasswort", ".");

Assert.Equal(user, _env.CurrentUser);
Assert.NotNull(_env.EncryptionKey);
Assert.NotNull(_env.CurrentGroup);
Assert.Equal(user, _userEnv.CurrentUser);
Assert.NotNull(_cryptEnv.EncryptionKey);
Assert.NotNull(_userEnv.CurrentGroup);
}

[Fact]
Expand All @@ -46,7 +47,7 @@ public void Login_ShouldNot_IfDatabaseDoesntExists() {
_userRepo.CheckPasswordAttempt(Arg.Any<string>(), Arg.Any<string>()).Returns(user);


_sut = new LoginService(_wrapper, _userRepo, _groupRepo, _cryptService, _settingsRepository, _env);
_sut = new LoginService(_wrapper, _userRepo, _groupRepo, _cryptService, _settingsRepository, _userEnv, _cryptEnv);

var ex = Assert.Throws<UserFeedbackException>(() => _sut.Login("TestUserName", "WhatAPassword", "."));
Assert.Equal("Database not found.", ex.Message);
Expand All @@ -59,7 +60,7 @@ public void Login_ShouldNot_IfUserNotFound() {
_userRepo.CheckPasswordAttempt(Arg.Any<string>(), Arg.Any<string>()).ReturnsNull();


_sut = new LoginService(_wrapper, _userRepo, _groupRepo, _cryptService, _settingsRepository, _env);
_sut = new LoginService(_wrapper, _userRepo, _groupRepo, _cryptService, _settingsRepository, _userEnv, _cryptEnv);

var ex = Assert.Throws<UserFeedbackException>(() => _sut.Login("TestUserName", "WhatAPassword", "."));
Assert.Equal("No such user found.", ex.Message);
Expand Down

0 comments on commit 43fafbc

Please sign in to comment.