forked from nissl-lab/toxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OLE2MetadataParserTest.cs
73 lines (71 loc) · 3.04 KB
/
OLE2MetadataParserTest.cs
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
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Toxy.Test
{
[TestFixture]
public class OLE2MetadataParserTest
{
[Test]
public void TestWord()
{
string path = Path.GetFullPath(TestDataSample.GetOLE2Path("TestEditTime.doc"));
ParserContext context = new ParserContext(path);
IMetadataParser parser = ParserFactory.CreateMetadata(context);
ToxyMetadata x = parser.Parse();
Assert.AreEqual(18, x.Count);
path = Path.GetFullPath(TestDataSample.GetOLE2Path("TestChineseProperties.doc"));
context = new ParserContext(path);
parser = (IMetadataParser)ParserFactory.CreateMetadata(context);
x = parser.Parse();
Assert.AreEqual(18, x.Count);
Assert.AreEqual("雅虎網站分類", x.Get("Comments").Value);
Assert.AreEqual("參考資料", x.Get("Title").Value);
}
[Test]
public void TestExcelFile()
{
string path = Path.GetFullPath(TestDataSample.GetExcelPath("comments.xls"));
ParserContext context = new ParserContext(path);
IMetadataParser parser = (IMetadataParser)ParserFactory.CreateMetadata(context);
ToxyMetadata x = parser.Parse();
Assert.AreEqual(8, x.Count);
Assert.AreEqual("Microsoft Excel", x.Get("ApplicationName").Value);
}
[Test]
public void TestPowerPoint()
{
string path = Path.GetFullPath(TestDataSample.GetOLE2Path("Test_Humor-Generation.ppt"));
ParserContext context = new ParserContext(path);
IMetadataParser parser = (IMetadataParser)ParserFactory.CreateMetadata(context);
ToxyMetadata x = parser.Parse();
Assert.AreEqual(8, x.Count);
Assert.AreEqual("Funny Factory", x.Get("Title").Value);
}
[Test]
public void TestCorelDrawFile()
{
string path = Path.GetFullPath(TestDataSample.GetOLE2Path("TestCorel.shw"));
ParserContext context = new ParserContext(path);
IMetadataParser parser = (IMetadataParser)ParserFactory.CreateMetadata(context);
ToxyMetadata x = parser.Parse();
Assert.AreEqual(6, x.Count);
Assert.AreEqual("thorsteb", x.Get("Author").Value);
Assert.AreEqual("thorsteb", x.Get("LastAuthor").Value);
}
[Test]
public void TestSolidWorksFile()
{
string path = Path.GetFullPath(TestDataSample.GetOLE2Path("TestSolidWorks.sldprt"));
ParserContext context = new ParserContext(path);
IMetadataParser parser = (IMetadataParser)ParserFactory.CreateMetadata(context);
ToxyMetadata x = parser.Parse();
Assert.AreEqual(10, x.Count);
Assert.AreEqual("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}", x.Get("ClassID").Value);
Assert.AreEqual("scj", x.Get("LastAuthor").Value);
}
}
}