Adding
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
using Moq;
|
||||
using LCU.API.Collections.RepoApi.HostedServices;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.Shared.Realtime.QueueLib.Models;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace LCU.API.Collections.RepoApiTests.HostedServices
|
||||
{
|
||||
public class RepoQueueConsumerServiceTest
|
||||
{
|
||||
private RepoApiConfiguration _repoApiConfig;
|
||||
private Mock<IQueueConnectionConfig> _mockQueueConnectionConfig;
|
||||
private RepoQueueConsumerService _repoQueueConsumerService;
|
||||
private Mock<IServiceScopeFactory> _mockScopeFactory;
|
||||
|
||||
public RepoQueueConsumerServiceTest()
|
||||
{
|
||||
_repoApiConfig = new RepoApiConfiguration()
|
||||
{
|
||||
QueueConsumerConfigs = StaticTestConfigs.GetQueueConsumerConfigs()
|
||||
};
|
||||
_mockQueueConnectionConfig = new Mock<IQueueConnectionConfig>();
|
||||
_mockScopeFactory = new Mock<IServiceScopeFactory>();
|
||||
_repoQueueConsumerService = new RepoQueueConsumerService(_mockQueueConnectionConfig.Object, _repoApiConfig, _mockScopeFactory.Object );
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Fact]
|
||||
public void BasicConstruction()
|
||||
{
|
||||
Assert.NotNull(_repoQueueConsumerService);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
using Moq;
|
||||
using LCU.API.Collections.RepoApi.HostedServices;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.DataAccess;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models.Producer;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using LCU.Shared.Collections.RepoApiLib.Repositories;
|
||||
using LCU.Shared.Realtime.QueueLib.Models;
|
||||
using LCU.Shared.Realtime.QueueLib.Queue;
|
||||
|
||||
namespace LCU.API.Collections.RepoApiTests.HostedServices
|
||||
{
|
||||
public class RepoQueueProducerServiceTests
|
||||
{
|
||||
private RepoApiConfiguration _repoApiConfig;
|
||||
private Mock<IRepoAccountService> _mockRepoAccountService;
|
||||
private Mock<IQueueConnectionConfig> _mockQueueConnectionConfig;
|
||||
private QueueItemProducer<ProcessingItem> _mockQueueItemProducer;
|
||||
private Mock<ISettingsService> _mockSettingsService;
|
||||
private Mock<IProcessingReceiptService> _mockProcessingReceiptService;
|
||||
private Mock<ICollectionsDao> _mockCollectionsDao;
|
||||
private RepoQueueProducerService _repoQueueProducerService;
|
||||
|
||||
public RepoQueueProducerServiceTests()
|
||||
{
|
||||
_repoApiConfig = new RepoApiConfiguration()
|
||||
{
|
||||
QueueConsumerConfigs = StaticTestConfigs.GetQueueConsumerConfigs()
|
||||
};
|
||||
_mockRepoAccountService = new Mock<IRepoAccountService>();
|
||||
_mockQueueConnectionConfig = new Mock<IQueueConnectionConfig>();
|
||||
_mockQueueItemProducer = new QueueItemProducer<ProcessingItem>(_mockQueueConnectionConfig.Object);
|
||||
_mockProcessingReceiptService = new Mock<IProcessingReceiptService>();
|
||||
_mockSettingsService = new Mock<ISettingsService>();
|
||||
_mockCollectionsDao = new Mock<ICollectionsDao>();
|
||||
_repoQueueProducerService = new RepoQueueProducerService(_mockQueueConnectionConfig.Object,
|
||||
_mockRepoAccountService.Object, _repoApiConfig, _mockSettingsService.Object,
|
||||
_mockCollectionsDao.Object, _mockProcessingReceiptService.Object);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void RetrieveRepoAccountsOfInterest_OK()
|
||||
{
|
||||
//setup
|
||||
_mockRepoAccountService.Setup(serv => serv.GetItemsForProcessing()).ReturnsAsync(new List<ProcessingItem>()
|
||||
{
|
||||
new ProcessingItem()
|
||||
{
|
||||
AccountNo = "123456-789"
|
||||
},
|
||||
new ProcessingItem()
|
||||
{
|
||||
AccountNo = "223456-789"
|
||||
},
|
||||
new ProcessingItem()
|
||||
{
|
||||
AccountNo = "323456-789"
|
||||
}
|
||||
});
|
||||
|
||||
//act
|
||||
var res = await _repoQueueProducerService.RetrieveRepoAccountsOfInterest();
|
||||
|
||||
//assert
|
||||
Assert.Equal(3, res.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void RetrieveRepoAccountsOfInterest_Exception()
|
||||
{
|
||||
//setup
|
||||
_mockRepoAccountService.Setup(serv => serv.GetItemsForProcessing()).ThrowsAsync(new ServerErrorException());
|
||||
|
||||
//act
|
||||
var res = await _repoQueueProducerService.RetrieveRepoAccountsOfInterest();
|
||||
|
||||
//assert
|
||||
Assert.Equal(0, res.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user