106 lines
3.7 KiB
C#
106 lines
3.7 KiB
C#
using NUnit.Framework;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace SplitPdf.Testing
|
|
{
|
|
public class PdfTests
|
|
{
|
|
List<string> splittedVorgänge;
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
this.splittedVorgänge = new List<string>()
|
|
{
|
|
"Rheinlanddamm 24 632-1-116 Zeichnungen 1-20 - Teil 1",
|
|
"Rheinlanddamm 24 632-1-116 Zeichnungen 1-20 - Teil 2",
|
|
"Rheinlanddamm 24 632-1-116 Zeichnungen 1-20 - Teil 3"
|
|
};
|
|
|
|
Pdf.splittedVorgänge = this.splittedVorgänge;
|
|
}
|
|
|
|
[Test]
|
|
public void CreateImportFilesTest()
|
|
{
|
|
Pdf.GenerateNewImportFiles(splittedVorgänge);
|
|
var files = Directory.GetFiles(@"D:\S2C_Testing\import");
|
|
bool newimportFile = false;
|
|
|
|
foreach (var item in files)
|
|
{
|
|
if(item.Contains("new"))
|
|
{
|
|
newimportFile = true;
|
|
}
|
|
}
|
|
Assert.IsTrue(newimportFile);
|
|
}
|
|
|
|
[Test]
|
|
public void CopyFilesBigger30MBTest()
|
|
{
|
|
var path = @"\\fsdeg002\DatenStA61_S\Bauvorhaben\0_EIGENSCAN\Nachbearbeitung\WORKING_DIR\Current";
|
|
var destination = @"\\fsdeg002\DatenStA61_S\Bauvorhaben\0_EIGENSCAN\Nachbearbeitung\30MB Schranke";
|
|
var files = Directory.GetFiles(path,"*.pdf", SearchOption.AllDirectories);
|
|
foreach (var file in files)
|
|
{
|
|
var fileInfo = new FileInfo(file);
|
|
if(fileInfo.Length>33000000)
|
|
{
|
|
File.Copy(file, Path.Combine(destination, fileInfo.Name));
|
|
}
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void CopyFilesSmaller30MBTest()
|
|
{
|
|
var path = @"\\fsdeg002\DatenStA61_S\Bauvorhaben\0_EIGENSCAN\Nachbearbeitung\WORKING_DIR\Current\alle Dokumente";
|
|
var destination = @"\\fsdeg002\DatenStA61_S\Bauvorhaben\0_EIGENSCAN\Nachbearbeitung\WORKING_DIR\Current";
|
|
var files = Directory.GetFiles(path, "*.pdf", SearchOption.AllDirectories);
|
|
foreach (var file in files)
|
|
{
|
|
var fileInfo = new FileInfo(file);
|
|
if (fileInfo.Length < 33000000)
|
|
{
|
|
File.Copy(file, Path.Combine(destination, fileInfo.Name));
|
|
}
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void MoveFoldersWithPlusOrCommaTest()
|
|
{
|
|
var path = @"\\fsdeg002\DatenStA61_S\Bauvorhaben\0_EIGENSCAN\Nachbearbeitung\WORKING_DIR";
|
|
var destination = @"\\fsdeg002\DatenStA61_S\Bauvorhaben\0_EIGENSCAN\Nachbearbeitung\Aussortiert_Plus_Komma";
|
|
var files = Directory.GetFiles(path, "*.pdf",SearchOption.AllDirectories);
|
|
|
|
|
|
foreach (var file in files)
|
|
{
|
|
var info = new FileInfo(file);
|
|
if(info.Name.Contains('+') || info.Name.Contains(','))
|
|
{
|
|
File.Move(file,Path.Combine(destination, Path.GetFileName(file)));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
[Test]
|
|
public void PullFilesTest()
|
|
{
|
|
string extension = "*.pdf";
|
|
var files = Directory.GetFiles(@"\\fsdeg002\DatenStA61_S\Bauvorhaben\0_EIGENSCAN\Nachbearbeitung\COMPRESSOR_DONE", extension,SearchOption.AllDirectories).ToList();
|
|
int countFiles = 0;
|
|
foreach (var file in files)
|
|
{
|
|
File.Copy(file, Path.Combine(@"S:\Bauvorhaben\0_EIGENSCAN\Nachbearbeitung\Aussortiert_Plus_Komma", Path.GetFileName(file)));
|
|
countFiles++;
|
|
}
|
|
}
|
|
}
|
|
} |