Example #1
0
            public void New_Instance_Of_ServiceManager_Returned()
            {
                // Arrange
                var serviceManager = new ReTry();

                var newServiceManager = serviceManager.ExecuteService <string, string>(() => "Hello World", 5);

                Assert.AreNotEqual(serviceManager, newServiceManager);
            }
Example #2
0
            public void New_Instance_Of_ServiceManager_Returned()
            {
                // Arrange
                var serviceManager = new ReTry();

                var newServiceManager = serviceManager.ExecuteService<string, string>(() => "Hello World", 5);

                Assert.AreNotEqual(serviceManager, newServiceManager);
            }
Example #3
0
            public void Works_Correctly_With_Action_Type()
            {
                var retry = new ReTry();

                var action = new Action(() => { throw new Exception("Some Exception"); });

                var result = retry.ExecuteService(action).IfServiceFailsThen<Exception>(exception => { }).Result;

                Assert.IsNotNull(result);
            }
Example #4
0
            public void Works_Correctly_With_Action_Type()
            {
                var retry = new ReTry();

                var action = new Action(() => { throw new Exception("Some Exception"); });

                var result = retry.ExecuteService(action).IfServiceFailsThen <Exception>(exception => { }).Result;

                Assert.IsNotNull(result);
            }
Example #5
0
            public void Passed_Method_Is_Called()
            {
                // Arrange
                var serviceManager = new ReTry();

                // Act
                var result = serviceManager
                    .ExecuteService<string, string>(() => "Hello World", 5)
                    .Result;

                // Assert
                Assert.AreEqual("Hello World", result.Result);
            }
Example #6
0
            public void Passed_Method_Is_Called()
            {
                // Arrange
                var serviceManager = new ReTry();

                // Act
                var result = serviceManager
                             .ExecuteService <string, string>(() => "Hello World", 5)
                             .Result;

                // Assert
                Assert.AreEqual("Hello World", result.Result);
            }
Example #7
0
            public void Less_Specific_Exception_Caught_When_More_Specific_Exception_Occurs()
            {
                // Arrange
                var serviceManager = new ReTry();

                // Act
                var result = serviceManager
                             .ExecuteService <string, string>(() => { throw new DirectoryNotFoundException("Boom"); })
                             .IfServiceFailsThen <Exception>(exception => "Hello World")
                             .Result;

                // Assert
                Assert.AreEqual("Hello World", result.FailureResult);
            }
Example #8
0
            public void Passed_Method_Is_Called_When_Exception_On_ExecuteService()
            {
                // Arrange
                var serviceManager = new ReTry();

                // Act
                var result = serviceManager
                             .ExecuteService <string, string>(() => { throw new DirectoryNotFoundException("Boom"); })
                             .IfServiceFailsThen <DirectoryNotFoundException>(exception => "Hello World")
                             .Result;

                // Assert
                Assert.AreEqual("Hello World", result.FailureResult);
            }
Example #9
0
            public void Exception_Is_Not_Specified_For_Handling_Returns_UnspecifiedExceptionHandler_Exception()
            {
                // Arrange
                var serviceManager = new ReTry();

                try
                {
                    var result = serviceManager
                    .ExecuteService<string, string>(() => { throw new Exception("Boom"); })
                    .Result;
                    Assert.Fail("We should not get here");
                }
                catch (Exception ex)
                {
                    Assert.AreEqual("No handler was found for the exception that was thrown. Make sure you've specified a handler through the IfServiceFailsThen method for this exception.", ex.Message);
                }
            }
Example #10
0
            public void Exception_Is_Not_Specified_For_Handling_Returns_UnspecifiedExceptionHandler_Exception()
            {
                // Arrange
                var serviceManager = new ReTry();

                try
                {
                    var result = serviceManager
                                 .ExecuteService <string, string>(() => { throw new Exception("Boom"); })
                                 .Result;
                    Assert.Fail("We should not get here");
                }
                catch (Exception ex)
                {
                    Assert.AreEqual("No handler was found for the exception that was thrown. Make sure you've specified a handler through the IfServiceFailsThen method for this exception.", ex.Message);
                }
            }
Example #11
0
        /// <inheritdoc />
        public override bool HandleDialog(Window window)
        {
            if (CanHandleDialog(window))
            {
                _hwnd = window.Hwnd;

                if (_pressReTry)
                {
                    ReTry.Click();
                }
                else
                {
                    Cancel.Click();
                }

                return(true);
            }
            return(false);
        }
Example #12
0
            public void Less_Specific_Exception_Caught_When_More_Specific_Exception_Occurs()
            {
                // Arrange
                var serviceManager = new ReTry();

                // Act
                var result = serviceManager
                    .ExecuteService<string, string>(() => { throw new DirectoryNotFoundException("Boom"); })
                    .IfServiceFailsThen<Exception>(exception => "Hello World")
                    .Result;

                // Assert
                Assert.AreEqual("Hello World", result.FailureResult);
            }
Example #13
0
            public void Passed_Method_Is_Called_When_Exception_On_ExecuteService()
            {
                // Arrange
                var serviceManager = new ReTry();

                // Act
                var result = serviceManager
                    .ExecuteService<string, string>(() => { throw new DirectoryNotFoundException("Boom"); })
                    .IfServiceFailsThen<DirectoryNotFoundException>(exception => "Hello World")
                    .Result;

                // Assert
                Assert.AreEqual("Hello World", result.FailureResult);
            }