#import <XCTest/XCTest.h> #import "GUIFactory.h" #import "Application.h" /** * Todo list: * - Test win os, should return true, when create win object. * - Test osx, should return true, when create osx object. */ @interface AbstractFactoryTests : XCTestCase @end @implementation AbstractFactoryTests - (void)setUp { [super setUp]; } - (void)tearDown { [super tearDown]; } //Helper - (id<GUIFactory>)createSpecificOSWithEnvironment:(NSString*)environment { if ([environment isEqualToString:@"osx"]) { return [[OSXFactory alloc] init]; } else if ([environment isEqualToString:@"win"]) { return [[WinFactory alloc] init]; } return nil; } - (void)testRunWinOS { //GIVEN NSString* inputedValue = @"win"; NSString* expectedValue1 = @"WinButton"; NSString* expectedValue2 = @"WinLabel"; //WHEN Application* app = [[Application alloc] initWithFactory:[self createSpecificOSWithEnvironment:inputedValue]]; //THEN XCTAssertEqualObjects(expectedValue1, app.buttonAction); XCTAssertEqualObjects(expectedValue2, app.labelAction); } - (void)testRunOSX { //GIVEN NSString* inputedValue = @"osx"; NSString* expectedValue1 = @"OSXButton"; NSString* expectedValue2 = @"OSXLabel"; //WHEN Application* app = [[Application alloc] initWithFactory:[self createSpecificOSWithEnvironment:inputedValue]]; //THEN XCTAssertEqualObjects(expectedValue1, app.buttonAction); XCTAssertEqualObjects(expectedValue2, app.labelAction); }