diff --git a/HW05UNIT/UNIT/Assert.cs b/HW05UNIT/UNIT/Assert.cs
index 6354500..f5195d5 100644
--- a/HW05UNIT/UNIT/Assert.cs
+++ b/HW05UNIT/UNIT/Assert.cs
@@ -1,23 +1,42 @@
namespace Unit;
+///
+/// Class for asserting statements
+///
public static class Assert
{
- public static void IsTrue(bool condition)
+ ///
+ /// Check if statement is true
+ ///
+ /// Statement to check
+ /// Thrown if statement is false
+ public static void IsTrue(bool statement)
{
- if (!condition)
+ if (!statement)
{
throw new Exception("ACHTUNG! Assert.IsTrue failed!");
}
}
- public static void IsFalse(bool condition)
+ ///
+ /// Check if statement is false
+ ///
+ /// Statement to check
+ /// Thrown if statement is true
+ public static void IsFalse(bool statement)
{
- if (condition)
+ if (statement)
{
throw new Exception("ACHTUNG! Assert.IsFalse failed");
}
}
+ ///
+ /// Check if two objects are equal
+ ///
+ /// First object
+ /// Second object
+ /// Thrown if objects are not equal
public static void AreEqual(object a, object b)
{
if (!a.Equals(b))
@@ -26,6 +45,12 @@ public static void AreEqual(object a, object b)
}
}
+ ///
+ /// Check if two objects are not equal
+ ///
+ /// First object
+ /// Second object
+ /// Thrown if objects are equal
public static void AreNotEqual(object a, object b)
{
if (a.Equals(b))
@@ -34,6 +59,11 @@ public static void AreNotEqual(object a, object b)
}
}
+ ///
+ /// Check if object is null
+ ///
+ /// Object
+ /// Thrown if object is not null
public static void IsNull(object a)
{
if (a != null)
@@ -42,6 +72,11 @@ public static void IsNull(object a)
}
}
+ ///
+ /// Check if object is not null
+ ///
+ /// Object
+ /// Thrown if object is null
public static void IsNotNull(object a)
{
if (a == null)
@@ -50,6 +85,11 @@ public static void IsNotNull(object a)
}
}
+ ///
+ /// Fails always
+ ///
+ /// Custom message to add in exception message
+ /// Thrown always. Contains custom message
public static void Fail(string message)
{
if (message.Count() != 0)
@@ -59,6 +99,9 @@ public static void Fail(string message)
throw new Exception($"ACHTUNG! Failed{message}");
}
+ ///
+ /// Fails always
+ ///
public static void Fail()
{
Fail("");
diff --git a/HW05UNIT/UNIT/Attributes.cs b/HW05UNIT/UNIT/Attributes.cs
index 8092783..514c806 100644
--- a/HW05UNIT/UNIT/Attributes.cs
+++ b/HW05UNIT/UNIT/Attributes.cs
@@ -1,5 +1,9 @@
namespace Unit;
+
+///
+/// Marks test methods
+///
[AttributeUsage(AttributeTargets.Method)]
public class Test : Attribute
{
@@ -8,16 +12,29 @@ public class Test : Attribute
public Test() {}
+ ///
+ ///
+ ///
+ /// Skips marked test method if not "NORMAL" value
public Test(string ignore)
{
Ignore = ignore;
}
+ ///
+ ///
+ ///
+ /// Expects exceptions, with method noted in expected array
public Test(string[] expected)
{
Expected = expected;
}
+ ///
+ ///
+ ///
+ /// Expects exceptions, with method noted in expected array
+ /// Skips marked test method if not "NORMAL" value
public Test(string[] expected, string ignore)
{
Expected = expected;
@@ -25,21 +42,35 @@ public Test(string[] expected, string ignore)
}
}
+
+///
+/// Marks method running before all test methods
+///
[AttributeUsage(AttributeTargets.Method)]
public class BeforeClass : Attribute
{
}
+
+///
+/// Marks method running after all test methods
+///
[AttributeUsage(AttributeTargets.Method)]
public class AfterClass : Attribute
{
}
+///
+/// Marks method running before each test method
+///
[AttributeUsage(AttributeTargets.Method)]
public class Before : Attribute
{
}
+///
+/// Marks method running after each test method
+///
[AttributeUsage(AttributeTargets.Method)]
public class After : Attribute
{
diff --git a/HW05UNIT/UNIT/InfoWriter.cs b/HW05UNIT/UNIT/InfoWriter.cs
index c2dec18..9a264cc 100644
--- a/HW05UNIT/UNIT/InfoWriter.cs
+++ b/HW05UNIT/UNIT/InfoWriter.cs
@@ -1,5 +1,9 @@
namespace Unit;
+
+///
+/// Writes stats and messages in pretty form using templates
+///
public static class InfoWriter
{
public static void WriteStatsSpecialMethods(Type t, Action? beforeClass, Action? afterClass,
diff --git a/HW05UNIT/UNIT/TestLauncher.cs b/HW05UNIT/UNIT/TestLauncher.cs
index c795983..554bb1e 100644
--- a/HW05UNIT/UNIT/TestLauncher.cs
+++ b/HW05UNIT/UNIT/TestLauncher.cs
@@ -2,7 +2,10 @@
namespace Unit;
-public class TestLauncher
+///
+/// Runs tests for every assembly in chosen path
+///
+public static class TestLauncher
{
private static List assemblies = new();
private static IEnumerable GetAssemblyPaths(string path)
@@ -25,6 +28,10 @@ private static bool IsAssemblyLoaded(string path)
return false;
}
+ ///
+ /// Runs tests for every assembly in chosen path
+ ///
+ /// Path to folder, holding the assemblies
public static void RunTests(string path)
{
var paths = GetAssemblyPaths(path);
diff --git a/HW05UNIT/UNIT/Tester.cs b/HW05UNIT/UNIT/Tester.cs
index aeb6109..2baaa57 100644
--- a/HW05UNIT/UNIT/Tester.cs
+++ b/HW05UNIT/UNIT/Tester.cs
@@ -1,10 +1,18 @@
using System.Diagnostics;
namespace Unit;
+
+///
+/// Runs test for given assembly
+///
public class Tester
{
private Assembly _asm;
+ ///
+ /// Creates tester object using path
+ ///
+ /// Assembly path
public Tester(Assembly asm)
{
_asm = asm;
@@ -150,7 +158,6 @@ private void RunSpecialMethods(Action? beforeClass, Action? afterClass,
failedCount++;
}
}
- // Console.WriteLine(stopwatch.ElapsedMilliseconds);
elapsedTime.Add(stopwatch.ElapsedMilliseconds);
stopwatch.Reset();
@@ -166,8 +173,12 @@ private void RunSpecialMethods(Action? beforeClass, Action? afterClass,
}
InfoWriter.WriteTestResults(elapsedTime, testMethods, failedCount, skippedCount);
- }
+ }
+
+ ///
+ /// Runst test methods in selected assembly
+ ///
public void RunTests()
{
foreach (var t in _asm.ExportedTypes)