mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
Invitation globale work
+ tests + new services + InvitationDto and IInvitationReqest
This commit is contained in:
@@ -204,12 +204,14 @@ public class InvitesRepositoryTests
|
||||
|
||||
// Act
|
||||
var result = repository.Exist(Guid.NewGuid());
|
||||
var result2 = repository.Exist(_fixture.Create<string>());
|
||||
|
||||
Assert.That(result, Is.False);
|
||||
Assert.That(result2, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Given_ExistInvitesCode_When_Exist_Then_Returns_False()
|
||||
public async Task Given_ExistInvites_When_Exist_Then_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
var invitation = _fixture.Create<Invitation>();
|
||||
@@ -226,11 +228,14 @@ public class InvitesRepositoryTests
|
||||
// Act
|
||||
var result = repository.Exist(invitation.Id);
|
||||
var result2 = repository.Exist(invitation);
|
||||
var result3 = repository.Exist(invitation.Code);
|
||||
|
||||
Assert.That(result, Is.True);
|
||||
Assert.That(result2, Is.True);
|
||||
Assert.That(result3, Is.True);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public async Task Given_InvalidInvites_When_Exist_Then_Returns_False()
|
||||
{
|
||||
|
||||
@@ -67,23 +67,24 @@ public class InvitationValidatorTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Given_InvalidEndDate_When_Exist_Then_Returns_False()
|
||||
public void Given_InvalidEndDatesAndIsActive_When_Exist_Then_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
var invitation = _fixture.Create<Invitation>();
|
||||
invitation.EndDate = invitation.DateCreated.AddDays(-1);
|
||||
|
||||
invitation.IsActive = true;
|
||||
// Act & Assert
|
||||
Assert.Throws<InvalidObjectException<Invitation>>( () => _messageValidator.Validate(invitation));
|
||||
Assert.That(_messageValidator.TryValidate(invitation), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Given_InvalidMaxParticipants_When_Exist_Then_Returns_False()
|
||||
public void Given_InvalidMaxParticipantsAndIsActive_When_Exist_Then_Returns_False()
|
||||
{
|
||||
// Arrange
|
||||
var invitation = _fixture.Create<Invitation>();
|
||||
invitation.MaxParticipants = new Random().Next(-5, 0);
|
||||
invitation.IsActive = true;
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<InvalidObjectException<Invitation>>( () => _messageValidator.Validate(invitation));
|
||||
|
||||
@@ -18,7 +18,6 @@ public class AuthServiceTests
|
||||
private Mock<IJwtService> _jwtServiceMock;
|
||||
private Mock<IUsersRepository> _usersRepositoryMock;
|
||||
private Mock<IAdminsRepository> _adminsRepositoryMock;
|
||||
private Mock<IInvitesRepository> _invitesRepositoryMock;
|
||||
|
||||
private IAccountService _accountService;
|
||||
|
||||
@@ -27,15 +26,22 @@ public class AuthServiceTests
|
||||
{
|
||||
_fixture = new Fixture();
|
||||
|
||||
_fixture.Behaviors
|
||||
.OfType<ThrowingRecursionBehavior>()
|
||||
.ToList()
|
||||
.ForEach(b => _fixture.Behaviors.Remove(b));
|
||||
|
||||
_fixture.Behaviors.Add(new OmitOnRecursionBehavior());
|
||||
|
||||
_usersRepositoryMock = new Mock<IUsersRepository>();
|
||||
_passwordHasherMock = new Mock<IPasswordHasher>();
|
||||
_jwtServiceMock = new Mock<IJwtService>();
|
||||
_adminsRepositoryMock = new Mock<IAdminsRepository>();
|
||||
|
||||
_accountService = new AuthService(
|
||||
_usersRepositoryMock.Object,
|
||||
_jwtServiceMock.Object,
|
||||
_passwordHasherMock.Object,
|
||||
_invitesRepositoryMock.Object,
|
||||
_adminsRepositoryMock.Object
|
||||
);
|
||||
}
|
||||
@@ -48,7 +54,7 @@ public class AuthServiceTests
|
||||
|
||||
// Act & Assert
|
||||
Assert.ThrowsAsync<UserAlreadyExistException>(async () => await _accountService.RegistrationAsync(
|
||||
_fixture.Create<string>(), _fixture.Create<string>(), _fixture.Create<string>()));
|
||||
_fixture.Create<string>(), _fixture.Create<string>(), _fixture.Create<Invitation>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -59,7 +65,7 @@ public class AuthServiceTests
|
||||
|
||||
// Act & Assert
|
||||
Assert.DoesNotThrowAsync(async () => await _accountService.RegistrationAsync(
|
||||
_fixture.Create<string>(), _fixture.Create<string>(), _fixture.Create<string>()));
|
||||
_fixture.Create<string>(), _fixture.Create<string>(), _fixture.Create<Invitation>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user