public void TestVerifyException() { Action wrapper = () => { throw new Exception(); }; var e = ExceptionUtilities.GetException(wrapper); Approvals.Verify(e); }
public void LambdaWithProcessFunction_ShouldThrow() { var input = new InputPipe <int>("input"); var exception = ExceptionUtilities.GetException(() => input.ProcessFunction(p => p.ToString())); Approvals.VerifyException(exception); }
public void VerifyException() { Action wrapper = () => throw new Exception("The Message"); var e = ExceptionUtilities.GetException(wrapper); Approvals.VerifyException(e); }
public void TestApprovalNamerFailureMessage() { var parser = new StackTraceParser(); var exception = ExceptionUtilities.GetException(() => parser.Parse(new StackTrace(6))); Approvals.Verify(exception.Message); }
public void TestMissingDots() { var e = ExceptionUtilities.GetException(() => GenericDiffReporter.RegisterTextFileTypes(".exe", "txt", ".error", "asp")); Approvals.Verify(e); }
public void TestVerifyException() { using (ApprovalTests.Namers.ApprovalResults.UniqueForOs()) { Action wrapper = () => { throw new Exception(); }; var e = ExceptionUtilities.GetException(wrapper); Approvals.Verify(e); } }
public void MissingValue() { var e = ExceptionUtilities.GetException( () => WindowsRegistryAssert.HasDword("Console", "IMadeThisUp", 1, "This Value is gone")); Approvals.Verify(e.Message); }
public void BadValue() { var e = ExceptionUtilities.GetException( () => WindowsRegistryAssert.HasDword("Console", "TrimLeadingZeros", 1984, "This should not be this value")); Approvals.Verify(e.Message); }
public void TestMissingDots() { using (ApprovalTests.Namers.ApprovalResults.UniqueForOs()) { var e = ExceptionUtilities.GetException(() => GenericDiffReporter.RegisterTextFileTypes(".exe", "txt", ".error", "asp")); Approvals.Verify(e); } }
public void TestDataSourceNames() { NamerFactory.Clear(); var exception = ExceptionUtilities.GetException( () => RdlcApprovals.VerifyReport(ReportName, GetAssembly(), "purposelyMisspelt", GetDefaultData())); Approvals.Verify(exception.Message); }
public void VerifyExceptionWithStacktrace() { using (Namers.ApprovalResults.UniqueForOs()) { Action wrapper = () => throw new Exception("https://github.com/approvals/ApprovalTests.Net/issues/242"); var e = ExceptionUtilities.GetException(wrapper); Approvals.VerifyExceptionWithStacktrace(e); } }
public void TestCallAfterException() { var a = new NUnitReporter(); var b = new RecordingReporter(); var multi = new MultiReporter(a, b); var exception = ExceptionUtilities.GetException(() => multi.Report("a", "r")); Assert.AreEqual("a,r", b.CalledWith); Assert.IsInstanceOf <Exception>(exception); }
public void TestException() { File.Create("received.notreal").Close(); try { var ex = ExceptionUtilities.GetException(() => new DiffReporter().Report("received.notreal", "received.notreal")); Assert.AreEqual("Could not find a diff tool for extension: .notreal", ex.Message); } finally { File.Delete("received.notreal"); } }
public void TestFailedBindings() { var viewModel = new TestViewModel(); Binding myBinding = new Binding(TestViewModel.MyPropertyPropertyName + "BOGUS"); myBinding.Source = viewModel; var e = ExceptionUtilities.GetException(() => WpfBindingsAssert.BindsWithoutError(viewModel, () => { var textBox = new TextBox(); textBox.SetBinding(TextBox.TextProperty, myBinding); return(textBox); })); Approvals.Verify(e.Message, s => Regex.Replace(s, @"\(HashCode=\d+\)", "(Hashcode)")); }
public void TestException() { if (DiffEngine.BuildServerDetector.Detected) { // DiffReporter not detected on CI return; } File.Create("received.notreal").Close(); try { var ex = ExceptionUtilities.GetException(() => new DiffReporter().Report("received.notreal", "received.notreal")); Assert.AreEqual("Could not find a diff tool for extension: .notreal", ex.Message); } finally { File.Delete("received.notreal"); } }
private static void RunKoan <T>(Func <T, Action> method, T k, bool pass) where T : Koans, new() { Exception exception = ExceptionUtilities.GetException(() => method(k).Invoke()); if (pass) { if (exception != null) { throw new Exception("Did Not Pass", exception); } } else { if (exception == null) { Assert.Fail("The method {0} is already passing".FormatWith(method.Method.Name)); } } }
void TestFailedBindings() { #region BindsWithoutError var viewModel = new ViewModel(); var myBinding = new Binding(nameof(ViewModel.MyProperty)) { Source = viewModel }; var exception = ExceptionUtilities.GetException( () => WpfBindingsAssert.BindsWithoutError(viewModel, () => { var textBox = new TextBox(); textBox.SetBinding(TextBox.TextProperty, myBinding); return(textBox); })); Assert.Null(exception); #endregion }
public void TestXunitReporterIsWorking() { var e = ExceptionUtilities.GetException(() => XUnit2Reporter.INSTANCE.AssertEqual("Hello", "Hello2")); Approvals.Verify(e.Message); }
public void TestException() { var ex = ExceptionUtilities.GetException(() => new ImageReporter().Report("received.notreal", "received.notreal")); Assert.AreEqual("ImageReporter Could not find a Reporter for file received.notreal", ex.Message); }
private static void AssertException <T>(Action action) where T : Exception { Assert.IsType <T>(ExceptionUtilities.GetException(action)); }
public static void AssertException <T>(Action action) where T : Exception { Assert.IsInstanceOfType(ExceptionUtilities.GetException(action), typeof(T)); }