Пример #1
0
        public void CustomNotifyUserManual_WhenCloseButtonClicked_ThenOKReturned()
        {
            // Simulate click on a button
            var mockFactory       = new Mock <IReactDialogFactory>();
            var mockBrowserDialog = new Mock <IBrowserDialog>();

            mockBrowserDialog.Setup(x => x.ShowDialog()).Callback(delegate
            {
                mockBrowserDialog.Object.CloseSource = null;
            });
            mockFactory.Setup(x => x.CreateReactDialog(It.IsAny <string>(), It.IsAny <object>()))
            .Returns(mockBrowserDialog.Object);

            var reporter = new HtmlErrorReporterBuilder()
                           .WithTestValues()
                           .BrowserDialogFactory(mockFactory.Object)
                           .Build();

            // CustomNotifyUserManual calls ErrorReport, so we should set it up
            ErrorReport.SetErrorReporter(reporter);

            // System Under Test
            var result = reporter.CustomNotifyUserManual(new ShowAlwaysPolicy(),
                                                         "Report", ErrorResult.Yes,
                                                         "Retry", ErrorResult.Retry,
                                                         "message");

            // Verification
            Assert.AreEqual(ErrorResult.OK, result);
        }
Пример #2
0
        public void CustomNotifyUserManual_WhenSecondaryActionButtonClicked_ThenSecondaryActionResultReturned()
        {
            // 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();

            // CustomNotifyUserManual calls ErrorReport, so we should set it up
            ErrorReport.SetErrorReporter(reporter);

            // System Under Test
            var result = reporter.CustomNotifyUserManual(new ShowAlwaysPolicy(),
                                                         "Report", ErrorResult.Yes,
                                                         "Retry", ErrorResult.Retry,
                                                         "message");

            // Verification
            Assert.AreEqual(ErrorResult.Retry, result);

            // Cleanup
        }