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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); } }
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); } }
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); }
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); }