Commit 537fc79e authored by Gertjan van Heertum's avatar Gertjan van Heertum
Browse files

Created a test-suite for the multithreaded problems

parent 77384831
......@@ -353,6 +353,7 @@
</ItemGroup>
<ItemGroup>
<None Include="Basic Shapes\DOM.cd" />
<None Include="Svg.nuspec" />
<None Include="svgkey.snk" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
......
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<description>TaxModel/PAW altered implementation of the Svg library</description>
</metadata>
</package>
\ No newline at end of file
......@@ -5,8 +5,6 @@ using ExCSS;
namespace Svg.UnitTests
{
/// <summary>
///This is a test class for CssQueryTest and is intended
///to contain all CssQueryTest Unit Tests
......
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Threading.Tasks;
using System.Xml;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Svg.UnitTests
{
[TestClass()]
public class MultiThreadingTest
{
private const string TestFile = @"d:\temp\test.svg";
private const int ExpectedSize = 600000;
private XmlDocument GetXMLDoc()
{
var xmlDoc = new XmlDocument();
if(!System.IO.File.Exists(TestFile)) { Assert.Inconclusive("Test file missing"); }
xmlDoc.LoadXml(System.IO.File.ReadAllText(TestFile));
return xmlDoc;
}
[TestMethod]
public void TestSingleThread()
{
LoadFile();
}
[TestMethod]
public void TestMultiThread()
{
bool valid = true;
Parallel.For(0, 10, (x) =>
{
try
{
LoadFile();
}
catch (Exception e)
{
Trace.WriteLine("Run error in parallel: " + e.Message);
valid = false;
}
});
Assert.IsTrue(valid, "One or more of the runs was invalid");
Trace.WriteLine("Done");
}
private void LoadFile()
{
var xml = GetXMLDoc();
Trace.WriteLine("Reading and drawing file");
SvgDocument d = SvgDocument.Open(xml);
var b = d.Draw();
Trace.WriteLine("Done reading file");
using (var ms = new MemoryStream())
{
b.Save(ms, ImageFormat.Png);
ms.Flush();
Assert.IsTrue(ms.Length >= ExpectedSize, "File does not match expected minimum size");
}
}
}
}
\ No newline at end of file
......@@ -49,6 +49,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CssQueryTest.cs" />
<Compile Include="MultiThreadingTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment