Commit e72d713a authored by Gertjan van Heertum's avatar Gertjan van Heertum Committed by mrbean-bremen
Browse files

Updated threading tests to use the resource file, updated the file loader in...

Updated threading tests to use the resource file, updated the file loader in the test helper to be flagged as obsolete and changed the working of the multi-threading fail test since this is not always failing with the error while processing the SVG. If it's not failing now it will be flagged inconclusive.
parent cbd07790
......@@ -15,3 +15,4 @@ Tests/**/*.csproj.user
Tests/**/*.suo
*.trx
Source/TestResults/
Source/.vs
......@@ -10,25 +10,24 @@ namespace Svg.UnitTests
[TestClass]
public class MultiThreadingTest : SvgTestHelper
{
protected override string TestFile { get { return @"d:\temp\test.svg"; } }
protected override int ExpectedSize { get { return 600000; } }
protected override string TestResource { get { return GetFullResourceString("Issue_Threading.TestFile.svg"); } }
protected override int ExpectedSize { get { return 100; } }
private void LoadFile()
{
LoadSvg(GetXMLDocFromFile());
LoadSvg(GetXMLDocFromResource());
}
[TestMethod]
public void TestSingleThread()
public void LoadSVGThreading_SingleThread_YieldsNoError()
{
LoadFile();
}
[TestMethod]
public void TestMultiThread()
public void LoadSVGThreading_MultiThread_YieldsNoErrorWhileInBounds()
{
Parallel.For(0, 10, (x) =>
{
......@@ -39,20 +38,24 @@ namespace Svg.UnitTests
[TestMethod]
[ExpectedException(typeof(SvgMemoryException))]
public void SVGGivesMemoryExceptionOnTooManyParallelTest()
public void LoadSVGThreading_MultiThread_GivesMemoryExceptionOnTooManyParallelTest()
{
try
{
Parallel.For(0, 50, (x) =>
Parallel.For(0, 100, (x) =>
{
LoadFile();
});
}
catch (AggregateException ex)
{
//We expect an SVG Memory Exception to be thrown, thats okay, otherwise fail
if (!(ex.InnerException is SvgMemoryException))
{
throw ex.InnerException;
}
}
Assert.Inconclusive("This test was expected to throw and SVGMemoryException, however this is higly dependent on the file and machine under test. This is not a fail reason.");
}
}
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 452 440">
<g id="SFixTitle" />
<g id="SContent">
<g transform="scale(1.33333)">
<g transform="matrix(1,0,0,1,0,0)">
<g>
<defs>
<clipPath id="CLIP0">
<path d="M0,0 L339,0 L339,330 L0,330 Z " />
</clipPath>
</defs>
<g clip-path="url(#CLIP0)">
<g transform="matrix(1,0,0,1,0,0)">
<image Id="Image1" x="0" y="0" width="339" height="330" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC45bDN+TgAAAPtJREFUKFMtjsFLhEAUh/1TO3YJOkYdg2DbXVqaZrNrBduiBuuhQ+jBNsXDBlI06jrm0EhsdYxu6vQz/fjN48374PE0pVTTNF0tZSmlrOsa3w4NU+AHwdw0w5UVPlkz01guH3uN54PA/vne+/iy3zeLz9/9h5XteV6rsep8SqW9xZKEizIX5WuSWvHByWQMpQkhDP04mh+yOImTFGFxeuXT0fUgy7JWL/ShmA3Wa57+B40eXR7djDjnWlVVU0o3O7sseuF5gTwzth0MJ+QUqj3Ndd07QsW9mxfirRBOHI6NCwz7y4HjOOSMmuYtQgjtHOg1wCrcAdD0I6X+AFY0+G5kPytUAAAAAElFTkSuQmCC" />
</g>
</g>
<g>
<path d="M170.25,165.75 L225.007827759,88.731620789 L225.007827759,88.731620789 C226.193939209,89.574920654 227.360412598,90.445503235 228.506332397,91.342681885 Z " stroke="none" stroke-width="0" fill="#C0504D" fill-opacity="1" transform="matrix(1,0,0,1,0,0)" />
</g>
<g />
<g transform="matrix(1,0,0,1,0,0)">
<defs>
<clipPath id="CLIP2">
<path d="M153.75,240 L183.75,240 L183.75,261 L153.75,261 Z " />
</clipPath>
</defs>
<g clip-path="url(#CLIP2)">
<g transform="matrix(1,0,0,1,156.57810974,259.06246948)">
<text x="0" y="-2.9615624" font-family="Impact" font-size="14.03999996" fill="#568ED4">64%</text>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
<defs />
</svg>
......@@ -99,6 +99,9 @@
<ItemGroup>
<EmbeddedResource Include="Resources\Issue281_Bounds\BoundsTest.svg" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Issue_Threading\TestFile.svg" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
......@@ -14,6 +14,7 @@ namespace Svg.UnitTests
/// <summary>
/// Test file path.
/// </summary>
[Obsolete("Try not to use the file loader, please use the resource loader to ensure working of tests on all systems")]
protected virtual string TestFile
{
get
......@@ -134,6 +135,7 @@ namespace Svg.UnitTests
/// Get xml document from <see cref="TestFile"/>.
/// </summary>
/// <returns>File data as xml document.</returns>
[Obsolete("Try not to use the file loader, please use the resource loader to ensure working of tests on all systems")]
protected virtual XmlDocument GetXMLDocFromFile()
{
return GetXMLDocFromFile(TestFile);
......@@ -145,6 +147,7 @@ namespace Svg.UnitTests
/// </summary>
/// <param name="file">File to load.</param>
/// <returns>File data as xml document.</returns>
[Obsolete("Try not to use the file loader, please use the resource loader to ensure working of tests on all systems")]
protected virtual XmlDocument GetXMLDocFromFile(string file)
{
if (!File.Exists(file))
......
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