Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Unit Testing
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "StaticTables.h"
@interface StaticTablesDataSourceTests : XCTestCase
@end
@implementation StaticTablesDataSourceTests
- (void)setUp {
[super setUp];
}
- (void)tearDown {
[super tearDown];
}
- (void)testNewDataSource {
JSMStaticDataSource *dataSource = [JSMStaticDataSource new];
XCTAssert( dataSource != nil, @"Datasource was not created." );
}
- (void)testNewSection {
JSMStaticSection *section = [JSMStaticSection section];
XCTAssert( section != nil, @"Section was not created." );
}
- (void)testNewSectionWithKey {
NSString *key = @"example";
JSMStaticSection *sectionWithKey = [JSMStaticSection sectionWithKey:key];
XCTAssert( sectionWithKey != nil, @"Section was not created with key." );
XCTAssert( [sectionWithKey.key isEqual:key], @"Section was not given key correctly." );
}
- (void)testNewRow {
JSMStaticRow *row = [JSMStaticRow row];
XCTAssert( row != nil, @"Row was not created." );
}
- (void)testNewRowWithKey {
NSString *key = @"example";
JSMStaticRow *rowWithKey = [JSMStaticRow rowWithKey:key];
XCTAssert( rowWithKey != nil, @"Row was not created with key." );
XCTAssert( [rowWithKey.key isEqual:key], @"Row was not given key correctly." );
}
- (void)testCreateSection {
JSMStaticDataSource *dataSource = [JSMStaticDataSource new];
JSMStaticSection *section = [dataSource createSection];
XCTAssert( section != nil, @"Section was not created." );
XCTAssert( [section.dataSource isEqual:dataSource], @"Section was not added to datasource." );
XCTAssert( [dataSource.sections containsObject:section], @"Section is not available in datasource sections array." );
}
- (void)testCreateRow {
JSMStaticSection *section = [JSMStaticSection section];
JSMStaticRow *row = [section createRow];
XCTAssert( row != nil, @"Row was not created." );
XCTAssert( [row.section isEqual:section], @"Row was not added to section." );
XCTAssert( [section.rows containsObject:row], @"Row is not available in section rows array." );
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment