Creado apartir del commit b888de6c92056de294456f581a56e25e734d4ab7 de develop
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using adas_core.Application.Repositories.Interfaces;
|
||||
using adas_core.Domain.Models.MongoModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MongoDB.Bson;
|
||||
using Moq;
|
||||
using ServiceConfigService = adas_core.Application.Services.ServiceConfigService;
|
||||
|
||||
namespace adas_core.Test.Services;
|
||||
|
||||
[TestFixture]
|
||||
public class ServiceConfigServiceTest
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_serviceConfigRepositoryMock = new Mock<IServiceConfigRepository>();
|
||||
|
||||
_logger = new Mock<ILogger<ServiceConfigService>>();
|
||||
|
||||
_serviceConfigService = new ServiceConfigService(
|
||||
_serviceConfigRepositoryMock.Object,
|
||||
_logger.Object
|
||||
);
|
||||
}
|
||||
|
||||
private ServiceConfigService _serviceConfigService;
|
||||
|
||||
private Mock<IServiceConfigRepository> _serviceConfigRepositoryMock;
|
||||
private Mock<ILogger<ServiceConfigService>> _logger;
|
||||
|
||||
private static ObjectId _id = ObjectId.GenerateNewId();
|
||||
|
||||
[Test]
|
||||
public async Task Get_Find_Id_Return_ServiceConfig()
|
||||
{
|
||||
var serviceConfig = new ServiceConfig
|
||||
{
|
||||
StrId = _id.ToString()
|
||||
};
|
||||
|
||||
_serviceConfigRepositoryMock.Setup(s => s.FindById(_id.ToString())).ReturnsAsync(serviceConfig);
|
||||
|
||||
var result = await _serviceConfigService.Get(serviceConfig.StrId);
|
||||
|
||||
Assert.That(result, Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Get_Not_Find_Id_Return_ServiceConfig()
|
||||
{
|
||||
var serviceConfig = new ServiceConfig
|
||||
{
|
||||
StrId = _id.ToString()
|
||||
};
|
||||
|
||||
_serviceConfigRepositoryMock.Setup(s => s.FindById(_id)).ReturnsAsync((ServiceConfig?)null);
|
||||
_serviceConfigRepositoryMock.Setup(s => s.FindById(It.IsAny<ObjectId>())).ReturnsAsync(serviceConfig);
|
||||
|
||||
var result = await _serviceConfigService.Get(_id.ToString());
|
||||
|
||||
Assert.That(result, Is.Not.Null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user