Updating
This commit is contained in:
+128
@@ -0,0 +1,128 @@
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
using LCU.Api.Internal.FileOperations.Validations;
|
||||
namespace LCU.Api.Internal.FileOperationsTests.Services.Validations;
|
||||
|
||||
public class FileValidationTest
|
||||
{
|
||||
[Fact]
|
||||
public void IsSourceEmpty_SourceEmpty_ReturnIsValid_False()
|
||||
{
|
||||
// arrange
|
||||
var sourcePath = "";
|
||||
var responseRequest = new RequestResponse();
|
||||
|
||||
// act
|
||||
responseRequest = FileValidation.ValidateSourceNotEmpty(sourcePath, responseRequest);
|
||||
|
||||
// assert
|
||||
Assert.False(responseRequest.IsSuccessful);
|
||||
Assert.Equal("Source is empty and is required.", responseRequest.MessageStack.FirstOrDefault());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsSourceEmpty_SourceNotEmpty_ReturnIsValid_True()
|
||||
{
|
||||
// arrange
|
||||
var sourcePath = "TESTSource";
|
||||
var responseRequest = new RequestResponse();
|
||||
|
||||
// act
|
||||
responseRequest = FileValidation.ValidateSourceNotEmpty(sourcePath, responseRequest);
|
||||
|
||||
// assert
|
||||
Assert.True(responseRequest.IsSuccessful);
|
||||
Assert.Empty(responseRequest.MessageStack);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsDestinationEmpty_DestinationEmpty_ReturnIsValid_False()
|
||||
{
|
||||
// arrange
|
||||
var sourcePath = "";
|
||||
var responseRequest = new RequestResponse();
|
||||
|
||||
// act
|
||||
responseRequest = FileValidation.ValidateDestinationNotEmpty(sourcePath, responseRequest);
|
||||
|
||||
// assert
|
||||
Assert.False(responseRequest.IsSuccessful);
|
||||
Assert.Equal("Destination is empty and is required.", responseRequest.MessageStack.FirstOrDefault());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsDestinationEmpty_DestinationNotEmpty_ReturnIsValid_True()
|
||||
{
|
||||
// arrange
|
||||
var destinationPath = "TESTDestination";
|
||||
var responseRequest = new RequestResponse();
|
||||
|
||||
// act
|
||||
responseRequest = FileValidation.ValidateDestinationNotEmpty(destinationPath, responseRequest);
|
||||
|
||||
// assert
|
||||
Assert.True(responseRequest.IsSuccessful);
|
||||
Assert.Empty(responseRequest.MessageStack);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsFilenameEmpty_FilenameEmpty_ReturnIsValid_False()
|
||||
{
|
||||
// arrange
|
||||
var filename = "";
|
||||
var responseRequest = new RequestResponse();
|
||||
|
||||
// act
|
||||
responseRequest = FileValidation.ValidateFilenameNotEmpty(filename, responseRequest);
|
||||
|
||||
// assert
|
||||
Assert.False(responseRequest.IsSuccessful);
|
||||
Assert.Equal("Filename is empty and is required.", responseRequest.MessageStack.FirstOrDefault());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsFilenameEmpty_FilenameNotEmpty_ReturnIsValid_True()
|
||||
{
|
||||
// arrange
|
||||
var filename = "TESTFilename";
|
||||
var responseRequest = new RequestResponse();
|
||||
|
||||
// act
|
||||
responseRequest = FileValidation.ValidateDestinationNotEmpty(filename, responseRequest);
|
||||
|
||||
// assert
|
||||
Assert.True(responseRequest.IsSuccessful);
|
||||
Assert.Empty(responseRequest.MessageStack);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsFilenameValid_FilenameNotValid_ReturnIsValid_False()
|
||||
{
|
||||
// arrange
|
||||
var filename = "/**";
|
||||
var responseRequest = new RequestResponse();
|
||||
|
||||
// act
|
||||
responseRequest = FileValidation.ValidateFilename(filename, responseRequest);
|
||||
|
||||
// assert
|
||||
Assert.False(responseRequest.IsSuccessful);
|
||||
Assert.Equal("File name is invalid.", responseRequest.MessageStack.FirstOrDefault());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsFilenameValid_FilenameValid_ReturnIsValid_True()
|
||||
{
|
||||
// arrange
|
||||
var filename = "TESTFilename";
|
||||
var responseRequest = new RequestResponse();
|
||||
|
||||
// act
|
||||
responseRequest = FileValidation.ValidateFilename(filename, responseRequest);
|
||||
|
||||
// assert
|
||||
Assert.True(responseRequest.IsSuccessful);
|
||||
Assert.Empty(responseRequest.MessageStack);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user