69 lines
2.3 KiB
C#
69 lines
2.3 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using LCU.API.Collections.RepoApi.Configuration;
|
|
using LCU.API.Collections.RepoApi.Services.AutoIms;
|
|
using Moq;
|
|
using Xunit;
|
|
|
|
namespace LCU.API.Collections.RepoApiTests.Processor
|
|
{
|
|
public class AutoImsDownloaderServiceTest
|
|
{
|
|
private readonly RepoApiConfiguration configuration;
|
|
private readonly Mock<IAuctionFtpClientService> mockAuctionFtpClientService;
|
|
private readonly IAutoImsDownloaderService autoImsDownloaderService;
|
|
|
|
public AutoImsDownloaderServiceTest()
|
|
{
|
|
configuration = new RepoApiConfiguration()
|
|
{
|
|
LocalDirectoryPath = "./Processor/SampleData"
|
|
};
|
|
mockAuctionFtpClientService = new Mock<IAuctionFtpClientService>();
|
|
autoImsDownloaderService =
|
|
new AutoImsDownloaderService(mockAuctionFtpClientService.Object, configuration);
|
|
}
|
|
|
|
[Fact]
|
|
public void Basic_Construct_Test()
|
|
{
|
|
Assert.NotNull(autoImsDownloaderService);
|
|
}
|
|
|
|
[Fact]
|
|
public void Basic_Download_Test()
|
|
{
|
|
mockAuctionFtpClientService.Setup(service => service.Download())
|
|
.Verifiable("Call Download");
|
|
var files = autoImsDownloaderService.DownLoadAuctionFiles();
|
|
mockAuctionFtpClientService.VerifyAll();
|
|
}
|
|
|
|
[Fact]
|
|
public void Combine_Local_Test()
|
|
{
|
|
var existing = new Dictionary<FileInfo, string>()
|
|
{
|
|
{new FileInfo("AutoImsDownloaderServiceTest.cs"), "success"}
|
|
};
|
|
var files = autoImsDownloaderService.CombineWithLocalFiles(existing);
|
|
Assert.NotNull(files);
|
|
Assert.Equal(3, files.Keys.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void Convert_To_File_List_Test()
|
|
{
|
|
var existing = new Dictionary<FileInfo, string>()
|
|
{
|
|
{new FileInfo("AutoImsDownloaderServiceTest.cs"), "success"},
|
|
{new FileInfo("LAND_DATA_TEST_FAIL.csv"), "error"},
|
|
{new FileInfo("LAND_DATA_TEST.csv"), "success"}
|
|
};
|
|
var files = autoImsDownloaderService.ConvertToFileList(existing);
|
|
Assert.NotNull(files);
|
|
Assert.Equal(2, files.Count());
|
|
}
|
|
}
|
|
} |