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,29 +70,38 @@ namespace Test.FixCommonErrors
|
|||||||
|
|
||||||
var asm = System.Reflection.Assembly.GetExecutingAssembly();
|
var asm = System.Reflection.Assembly.GetExecutingAssembly();
|
||||||
var stream = asm.GetManifestResourceStream("Test.Dictionaries.en_US.aff");
|
var stream = asm.GetManifestResourceStream("Test.Dictionaries.en_US.aff");
|
||||||
if (stream != null)
|
WriteStream(stream, Path.Combine(dictionaryFolder, "en_US.aff"));
|
||||||
{
|
|
||||||
using (Stream file = File.OpenWrite(Path.Combine(dictionaryFolder, "en_US.aff")))
|
|
||||||
{
|
|
||||||
CopyStream(stream, file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stream = asm.GetManifestResourceStream("Test.Dictionaries.en_US.dic");
|
stream = asm.GetManifestResourceStream("Test.Dictionaries.en_US.dic");
|
||||||
if (stream != null)
|
WriteStream(stream, Path.Combine(dictionaryFolder, "en_US.dic"));
|
||||||
{
|
|
||||||
using (Stream file = File.OpenWrite(Path.Combine(dictionaryFolder, "en_US.dic")))
|
|
||||||
{
|
|
||||||
CopyStream(stream, file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stream = asm.GetManifestResourceStream("Test.Dictionaries.names.xml");
|
stream = asm.GetManifestResourceStream("Test.Dictionaries.names.xml");
|
||||||
if (stream != null)
|
WriteStream(stream, Path.Combine(dictionaryFolder, "names.xml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly object WriteStreamLock = new Object();
|
||||||
|
|
||||||
|
private static void WriteStream(Stream stream, string fileName)
|
||||||
|
{
|
||||||
|
lock (WriteStreamLock)
|
||||||
{
|
{
|
||||||
using (Stream file = File.OpenWrite(Path.Combine(dictionaryFolder, "names.xml")))
|
if (stream != null)
|
||||||
{
|
{
|
||||||
CopyStream(stream, file);
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(fileName);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
using (Stream file = File.OpenWrite(fileName))
|
||||||
|
{
|
||||||
|
CopyStream(stream, file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Core\UUEncodingTest.cs" />
|
||||||
<Compile Include="Core\CharUtilsTest.cs" />
|
<Compile Include="Core\CharUtilsTest.cs" />
|
||||||
<Compile Include="Core\DialogTypeTest.cs" />
|
<Compile Include="Core\DialogTypeTest.cs" />
|
||||||
<Compile Include="Core\SeJsonParserTest.cs" />
|
<Compile Include="Core\SeJsonParserTest.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user