-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathProgram.cs
More file actions
82 lines (71 loc) · 2.92 KB
/
Copy pathProgram.cs
File metadata and controls
82 lines (71 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.IO;
using GerberLibrary;
using ICSharpCode.SharpZipLib.Zip;
namespace MigrationTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Testing GerberLibrary Migration...");
string testDir = Path.GetFullPath("TestGerbers");
string outDir = Path.GetFullPath("Output");
if (Directory.Exists(testDir)) Directory.Delete(testDir, true);
if (Directory.Exists(outDir)) Directory.Delete(outDir, true);
Directory.CreateDirectory(testDir);
Directory.CreateDirectory(outDir);
// Create dummy files
File.WriteAllText(Path.Combine(testDir, "board.gtl"), "G04 This is a test gerber file*");
File.WriteAllText(Path.Combine(testDir, "board.drl"), "M48*"); // Drill file
Console.WriteLine($"Created test files in {testDir}");
try
{
// Test Zipping
Console.WriteLine("Calling ZipGerberFolderToFactoryFolder...");
Gerber.ZipGerberFolderToFactoryFolder("TestBoard", testDir, outDir);
string zipPath = Path.Combine(outDir, "TestBoard_gerbers.zip");
if (File.Exists(zipPath))
{
Console.WriteLine($"SUCCESS: Zip file created at {zipPath}");
// Verify contents
using (ZipFile zf = new ZipFile(zipPath))
{
Console.WriteLine($"Zip contains {zf.Count} entries:");
foreach (ZipEntry e in zf)
{
Console.WriteLine($" - {e.Name}");
}
}
}
else
{
Console.WriteLine("FAILURE: Zip file not found.");
Environment.Exit(1);
}
// Test Reading (simulating reading logic)
Console.WriteLine("\nTesting Reading back...");
using (ZipFile zipRead = new ZipFile(zipPath))
{
foreach (ZipEntry e in zipRead)
{
if (!e.IsDirectory)
{
using (var s = zipRead.GetInputStream(e))
{
Console.WriteLine($" + Successfully opened stream for {e.Name}");
}
}
}
}
Console.WriteLine("SUCCESS: Reading Zip works.");
}
catch (Exception ex)
{
Console.WriteLine($"EXCEPTION: {ex.Message}");
Console.WriteLine(ex.StackTrace);
Environment.Exit(1);
}
}
}
}