public void SetNotifyUserOfProblemCustomParams_SecondaryActionButtonLabel() { var mockFactory = GetDefaultMockReactDialogFactory(); IBloomErrorReporter reporter = new HtmlErrorReporterBuilder() .WithTestValues() .BrowserDialogFactory(mockFactory.Object) .Build(); // System Under Test reporter.SetNotifyUserOfProblemCustomParams(extraButtonLabel: "Retry"); reporter.NotifyUserOfProblem(new ShowAlwaysPolicy(), null, "message"); // Verification mockFactory.Verify(x => x.CreateReactDialog( It.Is <string>(b => b == "problemReportBundle"), It.Is <object>(props => (string)props.GetType().GetProperty("level").GetValue(props) == ProblemLevel.kNotify && (string)props.GetType().GetProperty("secondaryLabel").GetValue(props) == "Retry") )); }
public void NotifyUserOfProblem_ReportButton(string reportLabel) { var mockFactory = GetDefaultMockReactDialogFactory(); IBloomErrorReporter reporter = new HtmlErrorReporterBuilder() .WithTestValues() .BrowserDialogFactory(mockFactory.Object) .Build(); // System Under Test reporter.SetNotifyUserOfProblemCustomParams(reportLabel); reporter.NotifyUserOfProblem(new ShowAlwaysPolicy(), new ApplicationException("fake exception"), "message"); mockFactory.Verify(x => x.CreateReactDialog( It.Is <string>(b => b == "problemReportBundle"), It.Is <object>(props => (string)props.GetType().GetProperty("level").GetValue(props) == ProblemLevel.kNotify && (string)props.GetType().GetProperty("reportLabel").GetValue(props) == reportLabel) ) ); }
public void SetNotifyUserOfProblemCustomParams_ReportButtonPresent(string exceptionMessage) { var mockFactory = GetDefaultMockReactDialogFactory(); IBloomErrorReporter reporter = new HtmlErrorReporterBuilder() .WithTestValues() .BrowserDialogFactory(mockFactory.Object) .Build(); var exceptionOrNull = exceptionMessage != null ? new ApplicationException(exceptionMessage) : null; // System Under Test reporter.SetNotifyUserOfProblemCustomParams(reportButtonLabel: "CustomReport"); reporter.NotifyUserOfProblem(new ShowAlwaysPolicy(), exceptionOrNull, "message"); // Verification mockFactory.Verify(x => x.CreateReactDialog( It.Is <string>(b => b == "problemReportBundle"), It.Is <object>(props => (string)props.GetType().GetProperty("level").GetValue(props) == ProblemLevel.kNotify && (string)props.GetType().GetProperty("reportLabel").GetValue(props) == "CustomReport") )); }
public void SetNotifyUserOfProblemCustomParams_SecondaryActionAutoInvoked() { // Simulate click on a button var mockFactory = new Mock <IReactDialogFactory>(); var mockBrowserDialog = new Mock <IBrowserDialog>(); mockBrowserDialog.SetupAllProperties(); // This is necessary for properties like CloseSource to set their values. mockBrowserDialog.Setup(x => x.ShowDialog()).Callback(delegate { mockBrowserDialog.Object.CloseSource = "closedByAlternateButton"; }); mockFactory.Setup(x => x.CreateReactDialog(It.IsAny <string>(), It.IsAny <object>())) .Returns(mockBrowserDialog.Object); var reporter = new HtmlErrorReporterBuilder() .WithTestValues() .BrowserDialogFactory(mockFactory.Object) .Build(); _testValue = ""; Action <Exception, string> action = delegate(Exception e, string s) { _testValue = "Retry was pressed"; }; try { // System Under Test reporter.SetNotifyUserOfProblemCustomParams("", null, "Retry", action); reporter.NotifyUserOfProblem(new ShowAlwaysPolicy(), null, "message"); // Verification Assert.AreEqual("Retry was pressed", _testValue); } finally { // Cleanup _testValue = ""; } }