Skip to content

Commit

Permalink
Merge pull request #64 from johankool/master
Browse files Browse the repository at this point in the history
Added test for service container, remove no longer functioning tests
  • Loading branch information
ijansch committed Feb 13, 2014
2 parents 0330565 + a060059 commit dbbd815
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 146 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "External/Kiwi"]
path = External/Kiwi
url = git://github.com/allending/Kiwi.git
2 changes: 1 addition & 1 deletion Classes/EFServiceContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ - (id)serviceForKey:(NSUInteger)serviceKey initializer:(id (^)(void))initializer
service = initializer();

if (service != nil) {
[self setService:service forKey:serviceKey];
[self.services setObject:service forKey:@(serviceKey)];
}
}

Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions Egeniq Tests/Egeniq Tests-Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
File renamed without changes.
4 changes: 2 additions & 2 deletions Egeniq.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Egeniq"
s.version = "0.1.0"
s.version = "0.1.1"
s.summary = "Egeniq Library for iOS projects"

s.description = <<-DESC
Expand Down Expand Up @@ -39,7 +39,7 @@ Pod::Spec.new do |s|
"Johan Kool" => "[email protected]",
"Felix De Vliegher" => "[email protected]"}

s.platform = :ios, '5.0'
s.platform = :ios, '5.1.1'

s.source = { :git => "https://github.com/egeniq/egeniq-ios.git", :tag => s.version.to_s }

Expand Down
251 changes: 124 additions & 127 deletions Egeniq.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion Egeniq.xcodeproj/xcshareddata/xcschemes/Egeniq.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
skipped = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C7955A88153E91CE00971465"
Expand All @@ -38,6 +38,16 @@
ReferencedContainer = "container:Egeniq.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C7BEB86A18ABD4D5008F62AE"
BuildableName = "Egeniq Tests.xctest"
BlueprintName = "Egeniq Tests"
ReferencedContainer = "container:Egeniq.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
3 changes: 0 additions & 3 deletions Egeniq.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions EgeniqTests/EFServiceContainerTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// EFServiceContainerTest.m
// Egeniq
//
// Created by Johan Kool on 13/2/2014.
// Copyright (c) 2014 Egeniq. All rights reserved.
//

#import <XCTest/XCTest.h>

#import "EFServiceContainer.h"
#import "EFServiceContainer-Protected.h"

@interface MYTestContainer : EFServiceContainer

@property (nonatomic, strong) NSObject *testService;

@end

@implementation MYTestContainer

- (NSObject *)testService {
return [self serviceForKey:1 initializer:^id{
return [[[NSObject alloc] init] autorelease];
}];
}

@end

@interface EFServiceContainerTest : XCTestCase

@end

@implementation EFServiceContainerTest

- (void)setUp {
[super setUp];
// Put setup code here; it will be run once, before the first test case.
}

- (void)tearDown {
// Put teardown code here; it will be run once, after the last test case.
[super tearDown];
}

- (void)testClass {
MYTestContainer *test = [MYTestContainer sharedInstance];
XCTAssertTrue([test isKindOfClass:[MYTestContainer class]], @"Ensure correct class is instantiated");
}

- (void)testSameService {
MYTestContainer *test = [MYTestContainer sharedInstance];
NSObject *service1 = test.testService;

MYTestContainer *test2 = [MYTestContainer sharedInstance];
NSObject *service2 = test2.testService;

XCTAssertEqualObjects(service1, service2, @"Expected the same service");
}

- (void)testSameServiceOnDifferentThreads {
__block NSObject *service1;
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
MYTestContainer *test = [MYTestContainer sharedInstance];
service1 = test.testService;
});

MYTestContainer *test2 = [MYTestContainer sharedInstance];
NSObject *service2 = test2.testService;

XCTAssertEqualObjects(service1, service2, @"Expected the same service");
}

@end
8 changes: 0 additions & 8 deletions EgeniqTests/EgeniqTests-Prefix.pch

This file was deleted.

1 change: 0 additions & 1 deletion External/Kiwi
Submodule Kiwi deleted from 67d5de

0 comments on commit dbbd815

Please sign in to comment.