예제 #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);
            }
예제 #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);
            }
예제 #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);
            }
예제 #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);
            }
예제 #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);
            }
예제 #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);
            }
예제 #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);
            }
예제 #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);
            }
예제 #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);
                }
            }
예제 #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);
                }
            }
예제 #11
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);
            }
예제 #12
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);
            }