Skip to content

Commit 8900d54

Browse files
author
Wayfarer
committed
Document my new tests
1 parent bba00ae commit 8900d54

2 files changed

Lines changed: 48 additions & 6 deletions

File tree

ImagingTests/ImagingLeakTests.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
1-
using System.Drawing;
1+
/*
2+
* COPYRIGHT: See COPYING in the top level directory
3+
* PROJECT: ImagingTests
4+
* FILE: ImagingLeakTests.cs
5+
* PURPOSE: Search for leaks in the ImagingFacade methods by running them multiple times and monitoring memory usage. This is a very basic test and should be used as a starting point for more comprehensive leak detection.
6+
* Should be run in a loop or with a profiler for best results, as small leaks might not be detected in a single run.
7+
* More calls will amplify the leak if it exists, but be mindful of test execution time.
8+
* Should be extended in the future to cover more methods and scenarios, especially those involving unmanaged resources.
9+
* PROGRAMER: Peter Geinitz (Wayfarer)
10+
*/
11+
12+
using System.Drawing;
213
using Imaging;
314

415
namespace ImagingTests
516
{
17+
/// <summary>
18+
/// Simple Memory checker for the ImagingFacade methods. It runs the method multiple times and checks if the memory usage increased significantly, which would indicate a leak.
19+
/// </summary>
620
[TestClass]
721
public class ImagingLeakTests
822
{
23+
/// <summary>
24+
/// Tests the pixelate for memory leaks.
25+
/// </summary>
926
[TestMethod]
1027
public void TestPixelateForMemoryLeaks()
1128
{
@@ -28,6 +45,9 @@ public void TestPixelateForMemoryLeaks()
2845
}, "Facade Resize and Convert Leak Test");
2946
}
3047

48+
/// <summary>
49+
/// Tests the filter leak.
50+
/// </summary>
3151
[TestMethod]
3252
public void TestFilterLeak()
3353
{

ImagingTests/LeakDetector.cs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
1-
using System.Diagnostics;
1+
/*
2+
* COPYRIGHT: See COPYING in the top level directory
3+
* PROJECT: ImagingTests
4+
* FILE: LeakDetector.cs
5+
* PURPOSE: Really basic memory leak detector for unit tests. It runs an action and checks if the memory usage increased significantly.
6+
* PROGRAMER: Peter Geinitz (Wayfarer)
7+
*/
8+
9+
using System.Diagnostics;
210

311
namespace ImagingTests
412
{
5-
public static class LeakDetector
13+
/// <summary>
14+
/// Really basic memory leak detector for unit tests. It runs an action and checks if the memory usage increased significantly.
15+
/// </summary>
16+
public static class LeakDetector
617
{
7-
// Switch this off in Production
8-
public static bool IsEnabled { get; set; } = true;
18+
/// <summary>
19+
/// Gets or sets a value indicating whether this instance is enabled.
20+
/// </summary>
21+
/// <value>
22+
/// <c>true</c> if this instance is enabled; otherwise, <c>false</c>.
23+
/// </value>
24+
public static bool IsEnabled { get; set; } = true;
925

10-
public static void Monitor(Action action, string label, long thresholdBytes = 1024 * 1024)
26+
/// <summary>
27+
/// Monitors the specified action.
28+
/// </summary>
29+
/// <param name="action">The action.</param>
30+
/// <param name="label">The label.</param>
31+
/// <param name="thresholdBytes">The threshold bytes.</param>
32+
public static void Monitor(Action action, string label, long thresholdBytes = 1024 * 1024)
1133
{
1234
if (!IsEnabled)
1335
{

0 commit comments

Comments
 (0)