forked from leetreveil/.NET-Auto-Update
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #120: Byteorder mark removal in UncSource removes first left an…
…gle bracket '<' of xml document (#123) * Fix removing bytorder mark not working see https://stackoverflow.com/a/3282915/542269 * Added test cases for differently encoded XML files Todo: Check XmlDeclaration for encoding and read file accordingly
- Loading branch information
1 parent
8f53d90
commit e00b096
Showing
8 changed files
with
140 additions
and
4 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
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,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using NAppUpdate.Framework; | ||
using NAppUpdate.Framework.Sources; | ||
using NAppUpdate.Framework.Conditions; | ||
using NAppUpdate.Framework.Tasks; | ||
using NAppUpdate.Framework.FeedReaders; | ||
|
||
namespace NAppUpdate.Tests.Sources | ||
{ | ||
/// <summary> | ||
/// Tests for different source file feed encodings: UTF-8 UTF-16LE UTF-16BE ANSI | ||
/// </summary> | ||
[TestClass] | ||
public class SourceEncodingTests | ||
{ | ||
private void ReadUpdateFeed(IUpdateSource sc) | ||
{ | ||
IUpdateFeedReader fr = new NauXmlFeedReader(); | ||
|
||
var tasks = fr.Read(sc.GetUpdatesFeed()); | ||
|
||
Assert.IsNotNull(tasks); | ||
Assert.IsTrue(tasks.Count == 3); | ||
Assert.IsTrue(tasks[0].Description.StartsWith("ÖÜÄ - some non 7-bit chars")); | ||
} | ||
|
||
[TestMethod] | ||
public void ReadUTF8File() | ||
{ | ||
ReadUpdateFeed(new UncSource(@"..\..\Sources\TestFeedXML.utf-8.xml", null)); | ||
} | ||
|
||
[TestMethod] | ||
public void ReadUTF8BOMFile() | ||
{ | ||
ReadUpdateFeed(new UncSource(@"..\..\Sources\TestFeedXML.utf-8.bom.xml", null)); | ||
} | ||
|
||
[TestMethod] | ||
public void ReadUTF16BigEndianFile() | ||
{ | ||
ReadUpdateFeed(new UncSource(@"..\..\Sources\TestFeedXML.utf-16.be.xml", null)); | ||
} | ||
|
||
[TestMethod] | ||
public void ReadUTF16LittleEndianFile() | ||
{ | ||
ReadUpdateFeed(new UncSource(@"..\..\Sources\TestFeedXML.utf-16.le.xml", null)); | ||
} | ||
|
||
[TestMethod] | ||
public void ReadANSIFile() | ||
{ | ||
ReadUpdateFeed(new UncSource(@"..\..\Sources\TestFeedXML.ansi.xml", null)); | ||
} | ||
} | ||
} |
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="ISO-8859-1" ?> | ||
<Feed> | ||
<Tasks> | ||
<FileUpdateTask hotswap="false" updateTo="file:///c:/test/htmlayout.dll" localPath="htmlayout.dll"> | ||
<Description>ÖÄÜ - some non 7-bit chars</Description> | ||
<Conditions> | ||
<FileVersionCondition what="below" version="3.3.2.10" /> | ||
<OSCondition type="and-not" bit="64" /> | ||
<FileSizeCondition type="and" what="above" size="1000" /> | ||
<FileDateCondition type="or" what="is" timestamp="20091010T000000" /> | ||
</Conditions> | ||
</FileUpdateTask> | ||
<FileUpdateTask updateTo="file:///c:/test/htmlayout.dll" localPath="htmlayout64.dll"> | ||
<Description>ÖÄÜ - some non 7-bit chars (for 64 bit platforms)</Description> | ||
<Conditions> | ||
<FileVersionCondition what="below" version="3.3.2.10" /> | ||
<OSCondition type="and" bit="64" /> | ||
<FileSizeCondition type="and-not" what="below" size="1000" /> | ||
<FileExistsCondition type="or" /> | ||
</Conditions> | ||
</FileUpdateTask> | ||
<FileUpdateTask hotswap="true" localPath="logo.png" updateTo="http://www.google.com/intl/en_ALL/images/srpr/logo1w.png" /> | ||
</Tasks> | ||
</Feed> |
Binary file not shown.
Binary file not shown.
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" ?> | ||
<Feed> | ||
<Tasks> | ||
<FileUpdateTask hotswap="false" updateTo="file:///c:/test/htmlayout.dll" localPath="htmlayout.dll"> | ||
<Description>ÖÜÄ - some non 7-bit chars</Description> | ||
<Conditions> | ||
<FileVersionCondition what="below" version="3.3.2.10" /> | ||
<OSCondition type="and-not" bit="64" /> | ||
<FileSizeCondition type="and" what="above" size="1000" /> | ||
<FileDateCondition type="or" what="is" timestamp="20091010T000000" /> | ||
</Conditions> | ||
</FileUpdateTask> | ||
<FileUpdateTask updateTo="file:///c:/test/htmlayout.dll" localPath="htmlayout64.dll"> | ||
<Description>ÖÜÄ - some non 7-bit chars (for 64 bit platforms)</Description> | ||
<Conditions> | ||
<FileVersionCondition what="below" version="3.3.2.10" /> | ||
<OSCondition type="and" bit="64" /> | ||
<FileSizeCondition type="and-not" what="below" size="1000" /> | ||
<FileExistsCondition type="or" /> | ||
</Conditions> | ||
</FileUpdateTask> | ||
<FileUpdateTask hotswap="true" localPath="logo.png" updateTo="http://www.google.com/intl/en_ALL/images/srpr/logo1w.png" /> | ||
</Tasks> | ||
</Feed> |
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" ?> | ||
<Feed> | ||
<Tasks> | ||
<FileUpdateTask hotswap="false" updateTo="file:///c:/test/htmlayout.dll" localPath="htmlayout.dll"> | ||
<Description>ÖÜÄ - some non 7-bit chars</Description> | ||
<Conditions> | ||
<FileVersionCondition what="below" version="3.3.2.10" /> | ||
<OSCondition type="and-not" bit="64" /> | ||
<FileSizeCondition type="and" what="above" size="1000" /> | ||
<FileDateCondition type="or" what="is" timestamp="20091010T000000" /> | ||
</Conditions> | ||
</FileUpdateTask> | ||
<FileUpdateTask updateTo="file:///c:/test/htmlayout.dll" localPath="htmlayout64.dll"> | ||
<Description>ÖÜÄ - some non 7-bit chars (for 64 bit platforms)</Description> | ||
<Conditions> | ||
<FileVersionCondition what="below" version="3.3.2.10" /> | ||
<OSCondition type="and" bit="64" /> | ||
<FileSizeCondition type="and-not" what="below" size="1000" /> | ||
<FileExistsCondition type="or" /> | ||
</Conditions> | ||
</FileUpdateTask> | ||
<FileUpdateTask hotswap="true" localPath="logo.png" updateTo="http://www.google.com/intl/en_ALL/images/srpr/logo1w.png" /> | ||
</Tasks> | ||
</Feed> |