FBExceptionHandlerTests.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. #import <XCTest/XCTest.h>
  10. #import "FBAlert.h"
  11. #import "FBExceptionHandler.h"
  12. #import "FBExceptions.h"
  13. @interface RouteResponseDouble : NSObject
  14. - (void)setHeader:(NSString *)field value:(NSString *)value;
  15. - (void)setStatusCode:(NSUInteger)code;
  16. - (void)respondWithData:(NSData *)data;
  17. @end
  18. @implementation RouteResponseDouble
  19. - (void)setHeader:(NSString *)field value:(NSString *)value {}
  20. - (void)setStatusCode:(NSUInteger)code {}
  21. - (void)respondWithData:(NSData *)data {}
  22. @end
  23. @interface FBExceptionHandlerTests : XCTestCase
  24. @property (nonatomic) FBExceptionHandler *exceptionHandler;
  25. @end
  26. @implementation FBExceptionHandlerTests
  27. - (void)setUp
  28. {
  29. self.exceptionHandler = [FBExceptionHandler new];
  30. }
  31. - (void)testMatchingErrorHandling
  32. {
  33. NSException *exception = [NSException exceptionWithName:FBElementNotVisibleException
  34. reason:@"reason"
  35. userInfo:@{}];
  36. [self.exceptionHandler handleException:exception
  37. forResponse:(RouteResponse *)[RouteResponseDouble new]];
  38. }
  39. - (void)testNonMatchingErrorHandling
  40. {
  41. NSException *exception = [NSException exceptionWithName:@"something"
  42. reason:@"reason"
  43. userInfo:@{}];
  44. [self.exceptionHandler handleException:exception
  45. forResponse:(RouteResponse *)[RouteResponseDouble new]];
  46. }
  47. @end