mirror of
https://github.com/zhigang1992/NTDCoreDataTableViewController.git
synced 2026-06-20 02:49:04 +08:00
Added code and fake objects to pass the test.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
7546396E18CC194600D43163 /* NTDFakeFetchedResultsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7546396D18CC194600D43163 /* NTDFakeFetchedResultsController.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 */; };
|
||||
@@ -42,6 +43,8 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
7546396C18CC194600D43163 /* NTDFakeFetchedResultsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NTDFakeFetchedResultsController.h; sourceTree = "<group>"; };
|
||||
7546396D18CC194600D43163 /* NTDFakeFetchedResultsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NTDFakeFetchedResultsController.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>"; };
|
||||
@@ -134,6 +137,8 @@
|
||||
75BD238F18CB0E2F005DD592 /* NTDCoreDataTableViewControllerTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7546396C18CC194600D43163 /* NTDFakeFetchedResultsController.h */,
|
||||
7546396D18CC194600D43163 /* NTDFakeFetchedResultsController.m */,
|
||||
75BD239518CB0E2F005DD592 /* NTDCoreDataTableViewControllerTests.m */,
|
||||
75BD239018CB0E2F005DD592 /* Supporting Files */,
|
||||
);
|
||||
@@ -238,6 +243,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7546396E18CC194600D43163 /* NTDFakeFetchedResultsController.m in Sources */,
|
||||
75BD239618CB0E2F005DD592 /* NTDCoreDataTableViewControllerTests.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
|
||||
@property (nonatomic, strong) NSFetchedResultsController *fetchedResultsController;
|
||||
|
||||
#pragma mark - Helper Methods
|
||||
|
||||
- (void)performFetch;
|
||||
|
||||
#pragma mark - Abstract Methods
|
||||
|
||||
// Returns identifier for UITableViewCell.
|
||||
|
||||
@@ -31,6 +31,15 @@
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Helper Methods
|
||||
|
||||
- (void)performFetch
|
||||
{
|
||||
if (self.fetchedResultsController) {
|
||||
[self.fetchedResultsController performFetch:nil];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - View Controller - Life Cycle
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
|
||||
@@ -6,7 +6,13 @@
|
||||
// Copyright (c) 2014 Nicholas Tian. All rights reserved.
|
||||
//
|
||||
|
||||
// Class Under Test
|
||||
#import "NTDCoreDataTableViewController.h"
|
||||
|
||||
// Collaborators
|
||||
#import "NTDFakeFetchedResultsController.h"
|
||||
|
||||
// Test Support
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@interface NTDCoreDataTableViewControllerTests : XCTestCase
|
||||
@@ -22,6 +28,7 @@
|
||||
{
|
||||
[super setUp];
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
sut = [[NTDCoreDataTableViewController alloc] init];
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
@@ -33,11 +40,11 @@
|
||||
- (void)testIfFRCIsNotNilThenFRCsPerformFetchIsCalledWhenSutsPerformFetchIsCalled
|
||||
{
|
||||
// given
|
||||
sut.fetchedResultsController = [[NSFetchedResultsController alloc] init];
|
||||
sut.fetchedResultsController = [[NTDFakeFetchedResultsController alloc] init];
|
||||
// when
|
||||
[sut performFetch];
|
||||
// then
|
||||
XCTAssertTrue(sut.fetchedResultsController.performFetchIsCalled);
|
||||
XCTAssertTrue([(NTDFakeFetchedResultsController *)(sut.fetchedResultsController) performFetchIsCalled]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// NTDFakeFetchedResultsController.h
|
||||
// NTDCoreDataTableViewController
|
||||
//
|
||||
// Created by Nicholas Tian on 3/9/14.
|
||||
// Copyright (c) 2014 Nicholas Tian. All rights reserved.
|
||||
//
|
||||
|
||||
#import <CoreData/CoreData.h>
|
||||
|
||||
@interface NTDFakeFetchedResultsController : NSFetchedResultsController
|
||||
|
||||
@property (nonatomic) BOOL performFetchIsCalled;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// NTDFakeFetchedResultsController.m
|
||||
// NTDCoreDataTableViewController
|
||||
//
|
||||
// Created by Nicholas Tian on 3/9/14.
|
||||
// Copyright (c) 2014 Nicholas Tian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTDFakeFetchedResultsController.h"
|
||||
|
||||
@implementation NTDFakeFetchedResultsController
|
||||
|
||||
- (BOOL)performFetch:(NSError *__autoreleasing *)error
|
||||
{
|
||||
self.performFetchIsCalled = YES;
|
||||
return [super performFetch:error];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user