public void FunctionBase_SafeExecute_ShouldCatchExceptions() { Func <Task <GenericResponse <object> > > action = () => throw new HttpResponseException(HttpStatusCode.BadRequest); functionBase .Invoking(x => x.SafeExecute(action)) .Should().NotThrow(); var result = functionBase.SafeExecute(action).Result; result.Should().BeOfType <StatusWithDataResult>(); }