126 lines
4.4 KiB
C#
126 lines
4.4 KiB
C#
using System;
|
|
using System.IO;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using NUnit.Framework;
|
|
using LCU.Library.Internal.DispatcherModels.Models;
|
|
using LCU.Library.Internal.DispatcherModels.Enums;
|
|
using LCU.Api.Internal.DispatcherSharedLib;
|
|
using LCU.Api.Internal.DispatcherSharedLib.BuilderServices;
|
|
using LCU.Library.Internal.FileOperationsModels.Models;
|
|
using LCU.Library.Internal.LcuHttpClient;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LCU.Api.Internal.DispatcherIntegrationTests;
|
|
|
|
public class DispatcherRequestBuilderTest
|
|
{
|
|
private readonly IServiceCollection services;
|
|
private readonly IRequestBuilderService _requestBuilder;
|
|
private const string TestPath1 = "\\\\zeus\\DataIntegrationsQA\\Test_FileOperationsApi_Folder_1";
|
|
private const string TestPath2 = "\\\\zeus\\DataIntegrationsQA\\Test_FileOperationsApi_Folder_1";
|
|
|
|
public DispatcherRequestBuilderTest()
|
|
{
|
|
services = new ServiceCollection();
|
|
|
|
var builder = new ConfigurationBuilder()
|
|
.SetBasePath(Path.Combine(AppContext.BaseDirectory))
|
|
.AddJsonFile("appsettings.integration.json");
|
|
var config = builder.Build();
|
|
services.AddDispatcherServices(config);
|
|
services.AddLCUHttpServices();
|
|
var serviceProvider = services.BuildServiceProvider();
|
|
_requestBuilder = serviceProvider.GetService<IRequestBuilderService>();
|
|
}
|
|
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
// !!!!!! In order to run these test you will need the following set up locally. !!!!!!
|
|
// 1.) Local Dispatcher Database.
|
|
// 2.) Local docker with Rabbit installed and running.
|
|
// 3.) Local instance of Dispatcher Api running along with other apis being tested (eg. FileOperationsApi).
|
|
// Which will also need to be using local Rabbit queues.
|
|
// 4.) Can use the the following two locations on QA for file operation testing.
|
|
// - \\zeus\DataIntegrationsQA\Test_FileOperationsApi_Folder_1
|
|
// - \\zeus\DataIntegrationsQA\Test_FileOperationsApi_Folder_2
|
|
// !!!!!! ---------------------------------------------------------------------- !!!!!!
|
|
}
|
|
|
|
[Test]
|
|
[Ignore("Can only be run locally.")]
|
|
public async Task Test_CreateDirectory()
|
|
{
|
|
//Create Job
|
|
var job = new JobDetails()
|
|
{
|
|
Name = "Test",
|
|
RequestingApplication = "Dispatcher Integration Test",
|
|
CreatedBy = "Dispatcher Integration Test",
|
|
CreatedAt = DateTime.Now,
|
|
NextRunTime = DateTime.Now
|
|
};
|
|
|
|
_requestBuilder.CreateJob(job);
|
|
|
|
//Create WorkItem
|
|
var createDirectoryRequest = new CreateDirectoryRequest()
|
|
{
|
|
DirectoryName = "FirstDispatcherIntegrationTest",
|
|
DirectoryPath = TestPath1
|
|
};
|
|
|
|
var workItemDetailsCreateDirectory = new WorkItemDetails()
|
|
{
|
|
Name = "Test",
|
|
Order = 0
|
|
};
|
|
|
|
_requestBuilder.AddWorkItem(createDirectoryRequest, workItemDetailsCreateDirectory, ActionType.CreateDirectory);
|
|
|
|
//Send
|
|
var result = await _requestBuilder.SendDispatcherRequest();
|
|
|
|
Assert.True(result);
|
|
}
|
|
|
|
[Test]
|
|
[Ignore("Can only be run locally.")]
|
|
public async Task Test_RenameDirectory()
|
|
{
|
|
//Create Job
|
|
var job = new JobDetails()
|
|
{
|
|
Name = "Test - Test_RenameDirectory",
|
|
RequestingApplication = "Dispatcher Integration Test - Test_RenameDirectory Builder",
|
|
CreatedBy = "Dispatcher Integration Test",
|
|
CreatedAt = DateTime.Now,
|
|
NextRunTime = DateTime.Now
|
|
};
|
|
|
|
_requestBuilder.CreateJob(job);
|
|
|
|
//Create WorkItem
|
|
var renameDirectoryRequest = new RenameDirectoryRequest()
|
|
{
|
|
SourceDirectoryName = "FirstDispatcherIntegrationTest",
|
|
SourceDirectoryPath = TestPath1,
|
|
NewDirectoryName = "RenameDispatcherIntegrationTest2"
|
|
};
|
|
|
|
var workItemDetailsCreateDirectory = new WorkItemDetails()
|
|
{
|
|
Name = "Test - Test_RenameDirectory",
|
|
Order = 0
|
|
};
|
|
|
|
_requestBuilder.AddWorkItem(renameDirectoryRequest, workItemDetailsCreateDirectory, ActionType.RenameDirectory);
|
|
|
|
//Send
|
|
var result = await _requestBuilder.SendDispatcherRequest();
|
|
|
|
Assert.True(result);
|
|
}
|
|
} |