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
Source/**/bin/ Source/**/bin/
Source/**/obj/ Source/**/obj/
Source/**/*.csproj.user Source/**/*.csproj.user
Source/**/*.suo Source/**/*.suo
Source/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache Source/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Samples/SVGViewer/obj/ Samples/SVGViewer/obj/
Samples/SVGViewer/bin/ Samples/SVGViewer/bin/
Samples/SVGViewer/SVGViewer.OpenCover.Settings Samples/SVGViewer/SVGViewer.OpenCover.Settings
Source/**/*.dll Source/**/*.dll
Source/**/*.pdb Source/**/*.pdb
Tests/**/bin/ Tests/**/bin/
Tests/**/obj/ Tests/**/obj/
Tests/**/*.csproj.user Tests/**/*.csproj.user
Tests/**/*.suo Tests/**/*.suo
*.trx *.trx
Source/TestResults/ Source/TestResults/
\ No newline at end of file Source/.vs
...@@ -9,26 +9,25 @@ namespace Svg.UnitTests ...@@ -9,26 +9,25 @@ namespace Svg.UnitTests
[TestClass] [TestClass]
public class MultiThreadingTest : SvgTestHelper public class MultiThreadingTest : SvgTestHelper
{ {
protected override string TestResource { get { return GetFullResourceString("Issue_Threading.TestFile.svg"); } }
protected override string TestFile { get { return @"d:\temp\test.svg"; } } protected override int ExpectedSize { get { return 100; } }
protected override int ExpectedSize { get { return 600000; } }
private void LoadFile() private void LoadFile()
{ {
LoadSvg(GetXMLDocFromFile()); LoadSvg(GetXMLDocFromResource());
} }
[TestMethod] [TestMethod]
public void TestSingleThread() public void LoadSVGThreading_SingleThread_YieldsNoError()
{ {
LoadFile(); LoadFile();
} }
[TestMethod] [TestMethod]
public void TestMultiThread() public void LoadSVGThreading_MultiThread_YieldsNoErrorWhileInBounds()
{ {
Parallel.For(0, 10, (x) => Parallel.For(0, 10, (x) =>
{ {
...@@ -39,20 +38,24 @@ namespace Svg.UnitTests ...@@ -39,20 +38,24 @@ namespace Svg.UnitTests
[TestMethod] [TestMethod]
[ExpectedException(typeof(SvgMemoryException))] public void LoadSVGThreading_MultiThread_GivesMemoryExceptionOnTooManyParallelTest()
public void SVGGivesMemoryExceptionOnTooManyParallelTest() {
{ try
try {
{ Parallel.For(0, 100, (x) =>
Parallel.For(0, 50, (x) => {
{ LoadFile();
LoadFile(); });
}); }
} catch (AggregateException ex)
catch (AggregateException ex) {
{ //We expect an SVG Memory Exception to be thrown, thats okay, otherwise fail
throw ex.InnerException; 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 @@ ...@@ -99,6 +99,9 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\Issue281_Bounds\BoundsTest.svg" /> <EmbeddedResource Include="Resources\Issue281_Bounds\BoundsTest.svg" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Issue_Threading\TestFile.svg" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.
......
...@@ -14,7 +14,8 @@ namespace Svg.UnitTests ...@@ -14,7 +14,8 @@ namespace Svg.UnitTests
/// <summary> /// <summary>
/// Test file path. /// Test file path.
/// </summary> /// </summary>
protected virtual string TestFile [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 get
{ {
...@@ -134,7 +135,8 @@ namespace Svg.UnitTests ...@@ -134,7 +135,8 @@ namespace Svg.UnitTests
/// Get xml document from <see cref="TestFile"/>. /// Get xml document from <see cref="TestFile"/>.
/// </summary> /// </summary>
/// <returns>File data as xml document.</returns> /// <returns>File data as xml document.</returns>
protected virtual XmlDocument GetXMLDocFromFile() [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); return GetXMLDocFromFile(TestFile);
} }
...@@ -145,7 +147,8 @@ namespace Svg.UnitTests ...@@ -145,7 +147,8 @@ namespace Svg.UnitTests
/// </summary> /// </summary>
/// <param name="file">File to load.</param> /// <param name="file">File to load.</param>
/// <returns>File data as xml document.</returns> /// <returns>File data as xml document.</returns>
protected virtual XmlDocument GetXMLDocFromFile(string file) [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)) if (!File.Exists(file))
Assert.Fail("Test file missing.", file); Assert.Fail("Test file missing.", 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