mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-28 15:02:35 +01:00
Work on unit tests
This commit is contained in:
parent
bce18c4f55
commit
82175c8e72
28
src/Test/Core/UUEncodingTest.cs
Normal file
28
src/Test/Core/UUEncodingTest.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Nikse.SubtitleEdit.Core.Common;
|
||||
|
||||
namespace Test.Core
|
||||
{
|
||||
[TestClass]
|
||||
public class UUEncodingTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void ForwardAndBackAgain()
|
||||
{
|
||||
var byteArray = new byte[byte.MaxValue];
|
||||
for (int i = byte.MinValue; i < byte.MaxValue; i++)
|
||||
{
|
||||
byteArray[i] = (byte)i;
|
||||
}
|
||||
|
||||
var text = UUEncoding.UUEncode(byteArray);
|
||||
var newBytes = UUEncoding.UUDecode(text);
|
||||
|
||||
Assert.AreEqual(byteArray.Length, newBytes.Length);
|
||||
for (int i = byte.MinValue; i < byte.MaxValue; i++)
|
||||
{
|
||||
Assert.AreEqual(byteArray[i], newBytes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -70,32 +70,41 @@ namespace Test.FixCommonErrors
|
||||
|
||||
var asm = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
var stream = asm.GetManifestResourceStream("Test.Dictionaries.en_US.aff");
|
||||
if (stream != null)
|
||||
{
|
||||
using (Stream file = File.OpenWrite(Path.Combine(dictionaryFolder, "en_US.aff")))
|
||||
{
|
||||
CopyStream(stream, file);
|
||||
}
|
||||
}
|
||||
WriteStream(stream, Path.Combine(dictionaryFolder, "en_US.aff"));
|
||||
|
||||
stream = asm.GetManifestResourceStream("Test.Dictionaries.en_US.dic");
|
||||
if (stream != null)
|
||||
{
|
||||
using (Stream file = File.OpenWrite(Path.Combine(dictionaryFolder, "en_US.dic")))
|
||||
{
|
||||
CopyStream(stream, file);
|
||||
}
|
||||
}
|
||||
WriteStream(stream, Path.Combine(dictionaryFolder, "en_US.dic"));
|
||||
|
||||
stream = asm.GetManifestResourceStream("Test.Dictionaries.names.xml");
|
||||
WriteStream(stream, Path.Combine(dictionaryFolder, "names.xml"));
|
||||
}
|
||||
|
||||
private static readonly object WriteStreamLock = new Object();
|
||||
|
||||
private static void WriteStream(Stream stream, string fileName)
|
||||
{
|
||||
lock (WriteStreamLock)
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
using (Stream file = File.OpenWrite(Path.Combine(dictionaryFolder, "names.xml")))
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(fileName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
using (Stream file = File.OpenWrite(fileName))
|
||||
{
|
||||
CopyStream(stream, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Merge short lines
|
||||
|
||||
|
@ -61,6 +61,7 @@
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Core\UUEncodingTest.cs" />
|
||||
<Compile Include="Core\CharUtilsTest.cs" />
|
||||
<Compile Include="Core\DialogTypeTest.cs" />
|
||||
<Compile Include="Core\SeJsonParserTest.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user