public void TestRecursionCount() { var sanitizer = new HtmlSanitizer(); using (var guard1 = new RecursionGuard(sanitizer)) { Assert.Equal(1, guard1.Depth); using (var guard2 = new RecursionGuard(sanitizer)) { Assert.Equal(2, guard1.Depth); Assert.Equal(2, guard2.Depth); } Assert.Equal(1, guard1.Depth); } }
public void TestRecursionMax() { var sanitizer = new HtmlSanitizer(); sanitizer.MaxRecursionDepth = 1; using (var guard1 = new RecursionGuard(sanitizer)) { Assert.Equal(1, guard1.Depth); Assert.Throws <InvalidOperationException>(() => { using (var guard2 = new RecursionGuard(sanitizer)) { Assert.Equal(2, guard2.Depth); } }); } }