-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.IO; | ||
|
||
namespace ILICheck.Web.XtfLog | ||
{ | ||
[TestClass] | ||
public class XtfLogParserTest | ||
{ | ||
[TestMethod] | ||
[DeploymentItem(@"testdata/xtflog/valid.xtf", "xtflog")] | ||
public void ParseValidXml() | ||
{ | ||
using var reader = new StreamReader(File.OpenRead(Path.Combine("xtflog", "valid.xtf"))); | ||
|
||
var logEntries = XtfLogParser.Parse(reader); | ||
|
||
Assert.AreEqual(2, logEntries.Count); | ||
|
||
var first = logEntries[0]; | ||
Assert.AreEqual("1", first.Tid); | ||
Assert.AreEqual("Error message 1", first.Message); | ||
Assert.AreEqual("Error", first.Type); | ||
Assert.AreEqual("Model.Topic.Class", first.ObjTag); | ||
Assert.AreEqual("Data source 1", first.DataSource); | ||
Assert.AreEqual(11, first.Line); | ||
Assert.AreEqual("Technical details 1", first.TechDetails); | ||
Assert.AreEqual(123.456m, first.Geometry.Coord.C1); | ||
Assert.AreEqual(234.567m, first.Geometry.Coord.C2); | ||
|
||
var second = logEntries[1]; | ||
Assert.AreEqual("2", second.Tid); | ||
Assert.AreEqual("Info message 2", second.Message); | ||
Assert.AreEqual("Info", second.Type); | ||
Assert.IsNull(second.ObjTag); | ||
Assert.IsNull(second.DataSource); | ||
Assert.IsNull(second.Line); | ||
Assert.IsNull(second.TechDetails); | ||
Assert.IsNull(second.Geometry); | ||
} | ||
|
||
[TestMethod] | ||
[DeploymentItem(@"testdata/xtflog/invalid.xtf", "xtflog")] | ||
public void ParseInvalidXml() | ||
{ | ||
using var reader = new StreamReader(File.OpenRead(Path.Combine("xtflog", "invalid.xtf"))); | ||
|
||
Assert.ThrowsException<InvalidOperationException>(() => XtfLogParser.Parse(reader)); | ||
} | ||
|
||
[TestMethod] | ||
[DeploymentItem(@"testdata/xtflog/empty.xtf", "xtflog")] | ||
public void ParseEmptyXml() | ||
{ | ||
using var reader = new StreamReader(File.OpenRead(Path.Combine("xtflog", "empty.xtf"))); | ||
|
||
var logEntries = XtfLogParser.Parse(reader); | ||
|
||
Assert.AreEqual(0, logEntries.Count); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<TRANSFER xmlns="http://www.interlis.ch/INTERLIS2.3"> | ||
<DATASECTION> | ||
<IliVErrors.ErrorLog BID="1"> | ||
</IliVErrors.ErrorLog> | ||
</DATASECTION> | ||
</TRANSFER> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<TRANSFER xmlns="http://www.interlis.ch/INTERLIS2.3"> | ||
<DATASECTION> | ||
<IliVErrors.ErrorLog BID="1"> | ||
<IliVErrors.ErrorLog.Error TID="1"> | ||
<Message>Error message 1</Message> | ||
<Type>Error</Type> | ||
<ObjTag>Model.Topic.Class</ObjTag> | ||
<DataSource>Data source 1</DataSource> | ||
<Line>11</Line> | ||
<TechDetails>Technical details 1</TechDetails> | ||
<Geometry> | ||
<COORD> | ||
<C1>123.456</C1> | ||
<C2>234.567</C2> | ||
</COORD> | ||
</Geometry> | ||
</IliVErrors.ErrorLog.Error> | ||
<IliVErrors.ErrorLog.Error TID="2"> | ||
<Message>Info message 2</Message> | ||
<Type>Info</Type> | ||
</IliVErrors.ErrorLog.Error> | ||
</DATASECTION> | ||
</TRANSFER> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<TRANSFER xmlns="http://www.interlis.ch/INTERLIS2.3"> | ||
<DATASECTION> | ||
<IliVErrors.ErrorLog BID="1"> | ||
<IliVErrors.ErrorLog.Error TID="1"> | ||
<Message>Error message 1</Message> | ||
<Type>Error</Type> | ||
<ObjTag>Model.Topic.Class</ObjTag> | ||
<DataSource>Data source 1</DataSource> | ||
<Line>11</Line> | ||
<TechDetails>Technical details 1</TechDetails> | ||
<Geometry> | ||
<COORD> | ||
<C1>123.456</C1> | ||
<C2>234.567</C2> | ||
</COORD> | ||
</Geometry> | ||
</IliVErrors.ErrorLog.Error> | ||
<IliVErrors.ErrorLog.Error TID="2"> | ||
<Message>Info message 2</Message> | ||
<Type>Info</Type> | ||
</IliVErrors.ErrorLog.Error> | ||
</IliVErrors.ErrorLog> | ||
</DATASECTION> | ||
</TRANSFER> |