Code and fake object to pass the test.

This commit is contained in:
NicholasTD07
2014-03-09 11:52:55 +08:00
parent 22194e7973
commit b14fe736d7
5 changed files with 45 additions and 1 deletions

View File

@@ -11,6 +11,7 @@
// Collaborators
#import "NTDFakeFetchedResultsController.h"
#import "NTDFakeTableView.h"
// Test Support
#import <XCTest/XCTest.h>
@@ -49,10 +50,12 @@
- (void)testTableViewsReloadDataIsCalledWhenSutsPerformFetchIsCalled
{
// given
sut.tableView = [[NTDFakeTableView alloc] init];
// when
[sut performFetch];
// then
XCTAssertTrue(sut.tableView.reloadDataIsCalled);
XCTAssertTrue([(NTDFakeTableView *)sut.tableView reloadDataIsCalled]);
}
@end

View File

@@ -0,0 +1,15 @@
//
// NTDFakeTableView.h
// NTDCoreDataTableViewController
//
// Created by Nicholas Tian on 3/9/14.
// Copyright (c) 2014 Nicholas Tian. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NTDFakeTableView : UITableView
@property (nonatomic) BOOL reloadDataIsCalled;
@end

View File

@@ -0,0 +1,19 @@
//
// NTDFakeTableView.m
// NTDCoreDataTableViewController
//
// Created by Nicholas Tian on 3/9/14.
// Copyright (c) 2014 Nicholas Tian. All rights reserved.
//
#import "NTDFakeTableView.h"
@implementation NTDFakeTableView
- (void)reloadData
{
[super reloadData];
self.reloadDataIsCalled = YES;
}
@end