public void CustomNotifyUserAuto_SecondaryActionButtonLabel() { var mockFactory = GetDefaultMockReactDialogFactory(); var reporter = new HtmlErrorReporterBuilder() .WithTestValues() .BrowserDialogFactory(mockFactory.Object) .Build(); // CustomNotifyUserAuto calls ErrorReport, so we should set it up ErrorReport.SetErrorReporter(reporter); // System Under Test reporter.CustomNotifyUserAuto("", "Retry", null, 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" && (string)props.GetType().GetProperty("message").GetValue(props) == "message") )); }
public void CustomNotifyUserAuto_IfInstanceVarIsDetailsThenStaysDetails() { var mockFactory = GetDefaultMockReactDialogFactory(); var reporter = new HtmlErrorReporterBuilder() .WithTestValues() .BrowserDialogFactory(mockFactory.Object) .Build(); // CustomNotifyUserAuto calls ErrorReport, so we should set it up ErrorReport.SetErrorReporter(reporter); // System Under Test reporter.CustomNotifyUserAuto("Details", null, null, null, "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) == "Details" && (string)props.GetType().GetProperty("message").GetValue(props) == "message") ) ); }
public void CustomNotifyUserAuto_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(); // CustomNotifyUserAuto calls ErrorReport, so we should set it up ErrorReport.SetErrorReporter(reporter); _testValue = ""; Action <Exception, string> action = delegate(Exception e, string s) { _testValue = "Retry was pressed"; }; // System Under Test reporter.CustomNotifyUserAuto("", "Retry", action, null, "message"); // Verification Assert.AreEqual("Retry was pressed", _testValue); // Cleanup _testValue = ""; }