mirror of
https://github.com/zhigang1992/NTDCoreDataTableViewController.git
synced 2026-01-12 22:40:11 +08:00
Test if Frc’s fetch fails then sut’s log is called.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
7546396E18CC194600D43163 /* NTDFakeFetchedResultsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7546396D18CC194600D43163 /* NTDFakeFetchedResultsController.m */; };
|
||||
7546397118CC1C4100D43163 /* NTDFakeTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7546397018CC1C4100D43163 /* NTDFakeTableView.m */; };
|
||||
7546397418CC256400D43163 /* NTDFakeCDTVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 7546397318CC256400D43163 /* NTDFakeCDTVC.m */; };
|
||||
75BD237A18CB0E2F005DD592 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75BD237918CB0E2F005DD592 /* Foundation.framework */; };
|
||||
75BD237F18CB0E2F005DD592 /* NTDCoreDataTableViewController.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 75BD237E18CB0E2F005DD592 /* NTDCoreDataTableViewController.h */; };
|
||||
75BD238118CB0E2F005DD592 /* NTDCoreDataTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 75BD238018CB0E2F005DD592 /* NTDCoreDataTableViewController.m */; };
|
||||
@@ -48,6 +49,8 @@
|
||||
7546396D18CC194600D43163 /* NTDFakeFetchedResultsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NTDFakeFetchedResultsController.m; sourceTree = "<group>"; };
|
||||
7546396F18CC1C4100D43163 /* NTDFakeTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NTDFakeTableView.h; sourceTree = "<group>"; };
|
||||
7546397018CC1C4100D43163 /* NTDFakeTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NTDFakeTableView.m; sourceTree = "<group>"; };
|
||||
7546397218CC256400D43163 /* NTDFakeCDTVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NTDFakeCDTVC.h; sourceTree = "<group>"; };
|
||||
7546397318CC256400D43163 /* NTDFakeCDTVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NTDFakeCDTVC.m; sourceTree = "<group>"; };
|
||||
75BD237618CB0E2F005DD592 /* libNTDCoreDataTableViewController.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libNTDCoreDataTableViewController.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
75BD237918CB0E2F005DD592 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
75BD237D18CB0E2F005DD592 /* NTDCoreDataTableViewController-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NTDCoreDataTableViewController-Prefix.pch"; sourceTree = "<group>"; };
|
||||
@@ -140,6 +143,8 @@
|
||||
75BD238F18CB0E2F005DD592 /* NTDCoreDataTableViewControllerTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7546397218CC256400D43163 /* NTDFakeCDTVC.h */,
|
||||
7546397318CC256400D43163 /* NTDFakeCDTVC.m */,
|
||||
7546396C18CC194600D43163 /* NTDFakeFetchedResultsController.h */,
|
||||
7546396D18CC194600D43163 /* NTDFakeFetchedResultsController.m */,
|
||||
7546396F18CC1C4100D43163 /* NTDFakeTableView.h */,
|
||||
@@ -250,6 +255,7 @@
|
||||
files = (
|
||||
7546397118CC1C4100D43163 /* NTDFakeTableView.m in Sources */,
|
||||
7546396E18CC194600D43163 /* NTDFakeFetchedResultsController.m in Sources */,
|
||||
7546397418CC256400D43163 /* NTDFakeCDTVC.m in Sources */,
|
||||
75BD239618CB0E2F005DD592 /* NTDCoreDataTableViewControllerTests.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#pragma mark - Helper Methods
|
||||
|
||||
- (void)performFetch;
|
||||
- (void)logFetchFailure;
|
||||
|
||||
#pragma mark - Abstract Methods
|
||||
|
||||
|
||||
@@ -41,6 +41,11 @@
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
- (void)logFetchFailure
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - View Controller - Life Cycle
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "NTDCoreDataTableViewController.h"
|
||||
|
||||
// Collaborators
|
||||
#import "NTDFakeCDTVC.h"
|
||||
#import "NTDFakeFetchedResultsController.h"
|
||||
#import "NTDFakeTableView.h"
|
||||
|
||||
@@ -58,4 +59,16 @@
|
||||
XCTAssertTrue([(NTDFakeTableView *)sut.tableView reloadDataIsCalled]);
|
||||
}
|
||||
|
||||
- (void)testLogIfFRCsFetchFailed
|
||||
{
|
||||
// given
|
||||
sut = [[NTDFakeCDTVC alloc] init];
|
||||
sut.fetchedResultsController = [[NTDFakeFetchedResultsController alloc] init];
|
||||
// when
|
||||
[(NTDFakeCDTVC *)sut setFetchWillFail:NO];
|
||||
[sut performFetch];
|
||||
// then
|
||||
XCTAssertTrue([(NTDFakeCDTVC *)sut loggedFailure]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
16
NTDCoreDataTableViewControllerTests/NTDFakeCDTVC.h
Normal file
16
NTDCoreDataTableViewControllerTests/NTDFakeCDTVC.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// NTDFakeCDTVC.h
|
||||
// NTDCoreDataTableViewController
|
||||
//
|
||||
// Created by Nicholas Tian on 3/9/14.
|
||||
// Copyright (c) 2014 Nicholas Tian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTDCoreDataTableViewController.h"
|
||||
|
||||
@interface NTDFakeCDTVC : NTDCoreDataTableViewController
|
||||
|
||||
@property (nonatomic) BOOL fetchWillFail;
|
||||
@property (nonatomic) BOOL loggedFailure;
|
||||
|
||||
@end
|
||||
24
NTDCoreDataTableViewControllerTests/NTDFakeCDTVC.m
Normal file
24
NTDCoreDataTableViewControllerTests/NTDFakeCDTVC.m
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// NTDFakeCDTVC.m
|
||||
// NTDCoreDataTableViewController
|
||||
//
|
||||
// Created by Nicholas Tian on 3/9/14.
|
||||
// Copyright (c) 2014 Nicholas Tian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTDFakeCDTVC.h"
|
||||
|
||||
@interface NTDFakeCDTVC ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTDFakeCDTVC
|
||||
|
||||
- (void)logFetchFailure
|
||||
{
|
||||
[super logFetchFailure];
|
||||
|
||||
self.loggedFailure = YES;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user