mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
test to make server
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
using Govor.Application.Services;
|
||||
|
||||
namespace Govor.Application.Tests.Services;
|
||||
|
||||
[TestFixture]
|
||||
public class SynchingServiceTests
|
||||
{
|
||||
private readonly SynchingService _sut; // System Under Test
|
||||
|
||||
public SynchingServiceTests()
|
||||
{
|
||||
_sut = new SynchingService();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NormalizeNewlines_ShouldReturnEmptyString_WhenInputIsEmpty()
|
||||
{
|
||||
// Act
|
||||
var result = _sut.NormalizeNewlines(string.Empty);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(string.Empty));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NormalizeNewlines_ShouldReturnNull_WhenInputIsNull()
|
||||
{
|
||||
// Arrange
|
||||
string input = null;
|
||||
|
||||
// Act
|
||||
var result = _sut.NormalizeNewlines(input);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NormalizeNewlines_ShouldNotChangeUnixStyleNewlines_WhenInputIsLF()
|
||||
{
|
||||
// Arrange
|
||||
const string input = "Line 1\nLine 2\nLine 3";
|
||||
|
||||
// Act
|
||||
var result = _sut.NormalizeNewlines(input);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(input));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NormalizeNewlines_ShouldConvertWindowsStyleNewlines_WhenInputIsCRLF()
|
||||
{
|
||||
// Arrange
|
||||
const string input = "Line 1\r\nLine 2\r\nLine 3";
|
||||
const string expected = "Line 1\nLine 2\nLine 3";
|
||||
|
||||
// Act
|
||||
var result = _sut.NormalizeNewlines(input);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NormalizeNewlines_ShouldConvertMacStyleNewlines_WhenInputIsCR()
|
||||
{
|
||||
// Arrange
|
||||
const string input = "Line 1\rLine 2\rLine 3";
|
||||
const string expected = "Line 1\nLine 2\nLine 3";
|
||||
|
||||
// Act
|
||||
var result = _sut.NormalizeNewlines(input);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NormalizeNewlines_ShouldHandleMixedNewlines_WhenInputIsMixed()
|
||||
{
|
||||
// Arrange
|
||||
const string input = "Line 1\r\nLine 2\rLine 3\nLine 4";
|
||||
const string expected = "Line 1\nLine 2\nLine 3\nLine 4";
|
||||
|
||||
// Act
|
||||
var result = _sut.NormalizeNewlines(input);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NormalizeNewlines_ShouldHandleTextWithoutNewlines()
|
||||
{
|
||||
// Arrange
|
||||
const string input = "This is a single line of text.";
|
||||
|
||||
// Act
|
||||
var result = _sut.NormalizeNewlines(input);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(input));
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -9,11 +9,11 @@ using Moq;
|
||||
namespace Govor.Application.Tests.Services;
|
||||
|
||||
[TestFixture]
|
||||
public class UserGroupsServiceTests
|
||||
public class UserGroupsGetterServiceTests
|
||||
{
|
||||
private Fixture _fixture;
|
||||
private Mock<IGroupsRepository> _repositoryMock;
|
||||
private IUserGroupsService _service;
|
||||
private IUserGroupsGetterService _getterService;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
@@ -29,7 +29,7 @@ public class UserGroupsServiceTests
|
||||
|
||||
_repositoryMock = new Mock<IGroupsRepository>();
|
||||
|
||||
_service = new UserGroupsService(_repositoryMock.Object);
|
||||
_getterService = new UserGroupsGetterService(_repositoryMock.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -43,7 +43,7 @@ public class UserGroupsServiceTests
|
||||
.ReturnsAsync([chats.First()]);
|
||||
|
||||
// Act
|
||||
var result = await _service.GetUserGroupsAsync(userId);
|
||||
var result = await _getterService.GetUserGroupsAsync(userId);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.Not.Null);
|
||||
@@ -61,7 +61,7 @@ public class UserGroupsServiceTests
|
||||
.ThrowsAsync(new NotFoundByKeyException<Guid>(userId));
|
||||
|
||||
// Act
|
||||
var result = await _service.GetUserGroupsAsync(userId);
|
||||
var result = await _getterService.GetUserGroupsAsync(userId);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.Not.Null);
|
||||
@@ -20,6 +20,7 @@ public class UserSessionRefresherTests
|
||||
private Mock<IJwtService> _jwtServiceMock;
|
||||
private Mock<ILogger<UserSessionRefresher>> _loggerMock;
|
||||
private Mock<IOptions<JwtRefreshOption>> _optionsMock;
|
||||
private Mock<IJwtTokenHasher> _jwtTokenHasherMock;
|
||||
private JwtRefreshOption _options;
|
||||
private UserSessionRefresher _refresher;
|
||||
private const string OldRefreshToken = "old-refresh-token";
|
||||
@@ -36,6 +37,7 @@ public class UserSessionRefresherTests
|
||||
_jwtServiceMock = new Mock<IJwtService>();
|
||||
_loggerMock = new Mock<ILogger<UserSessionRefresher>>();
|
||||
_optionsMock = new Mock<IOptions<JwtRefreshOption>>();
|
||||
_jwtTokenHasherMock = new Mock<IJwtTokenHasher>();
|
||||
|
||||
_options = new JwtRefreshOption { RefreshTokenLifetimeDays = 30 };
|
||||
|
||||
@@ -46,6 +48,7 @@ public class UserSessionRefresherTests
|
||||
_loggerMock.Object,
|
||||
_usersRepoMock.Object,
|
||||
_optionsMock.Object,
|
||||
_jwtTokenHasherMock.Object,
|
||||
_jwtServiceMock.Object);
|
||||
|
||||
_user = new User
|
||||
|
||||
Reference in New Issue
Block a user