using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
public static Test New(string p)
return new Test() { data = p };
public async Task<T> FuncAsync<T>() where T: class
Program.Assert.Fail("ran FuncAsync<T>");
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(await FuncAsync());
public async Task<string> FuncAsync()
Program.Assert.True(true, "ran FuncAsync");
public static void Main()
dynamic t = new { UID="123", SomeProperty="SomeProperty" };
Console.WriteLine("Not correct:");
Test.New(t.UID).FuncAsync();
Console.WriteLine("Correct");
Test.New(uid).FuncAsync();
public static int Total = 0;
public static int Passed = 0;
public static int Failed = 0;
public static void Statistics()
Console.WriteLine("Statistics:");
Console.WriteLine("No assertions run.");
"- Passing: " + Passed + " (" + (Passed * 100 / Total) + "%)" + Environment.NewLine +
"- Failing: " + Failed + " (" + (100 - (Passed * 100 / Total)) + "%)" + Environment.NewLine +
private static void Report(bool success, string description = "")
(success ? "Success" : "Failure") +
(string.IsNullOrWhiteSpace(description) ? "." : (": " + description))
public static void True(bool result, string description = "")
Report(result, description);
public static void False(bool result, string description = "")
True(!result, description);
public static void AreEqual<T>(T expected, T actual, string description = "")
Report(expected.Equals(actual), description);
public static void AreNotEqual<T>(T expected, T actual, string description = "")
Report(!expected.Equals(actual), description);
public static void Throws<T>(Action function, string description = "")
Report(false, description);
Report(e.GetType() == typeof(T), description);
public static void Null(object what, string description = "")
Report(what == null, description);
public static void NotNull(object what, string description = "")
Report(what != null, description);
public static void Fail(string description = "")
Report(false, description);