Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0c68a2f624
Fetching contributors…

Cannot retrieve contributors at this time

92 lines (68 sloc) 4.397 kb
#import "CCMBuildNotificationFactoryTest.h"
#import "CCMProject.h"
@implementation CCMBuildNotificationFactoryTest
- (void)setUp
{
factory = [[[CCMBuildNotificationFactory alloc] init] autorelease];
}
- (NSMutableDictionary *)createProjectInfoWithActivity:(NSString *)activity lastBuildStatus:(NSString *)status
{
NSMutableDictionary *info = [NSMutableDictionary dictionary];
[info setObject:@"connectfour" forKey:@"name"];
[info setObject:activity forKey:@"activity"];
[info setObject:status forKey:@"lastBuildStatus"];
[info setObject:[NSCalendarDate calendarDate] forKey:@"lastBuildDate"];
return info;
}
- (void)testCreatesSuccessfulBuildCompleteNotification
{
NSDictionary *pi1 = [self createProjectInfoWithActivity:CCMBuildingActivity lastBuildStatus:CCMSuccessStatus];
NSDictionary *pi2 = [self createProjectInfoWithActivity:CCMSleepingActivity lastBuildStatus:CCMSuccessStatus];
NSNotification *notification = [factory buildCompleteNotificationForOldProjectInfo:pi1 andNewProjectInfo:pi2];
STAssertNotNil(notification, @"Should have created a notification.");
STAssertEqualObjects(CCMBuildCompleteNotification, [notification name], @"Should have created correct notification.");
NSDictionary *userInfo = [notification userInfo];
STAssertEqualObjects(@"connectfour", [userInfo objectForKey:@"projectName"], @"Should have set project name.");
STAssertEqualObjects(CCMSuccessfulBuild, [userInfo objectForKey:@"buildResult"], @"Should have set correct build result.");
}
- (void)testCreatesBrokenBuildCompleteNotification
{
NSDictionary *pi1 = [self createProjectInfoWithActivity:CCMBuildingActivity lastBuildStatus:CCMSuccessStatus];
NSDictionary *pi2 = [self createProjectInfoWithActivity:CCMSleepingActivity lastBuildStatus:CCMFailedStatus];
NSNotification *notification = [factory buildCompleteNotificationForOldProjectInfo:pi1 andNewProjectInfo:pi2];
NSDictionary *userInfo = [notification userInfo];
STAssertEqualObjects(CCMBrokenBuild, [userInfo objectForKey:@"buildResult"], @"Should have set correct build result.");
}
- (void)testCreatesFixedBuildCompleteNotification
{
NSDictionary *pi1 = [self createProjectInfoWithActivity:CCMBuildingActivity lastBuildStatus:CCMFailedStatus];
NSDictionary *pi2 = [self createProjectInfoWithActivity:CCMSleepingActivity lastBuildStatus:CCMSuccessStatus];
NSNotification *notification = [factory buildCompleteNotificationForOldProjectInfo:pi1 andNewProjectInfo:pi2];
NSDictionary *userInfo = [notification userInfo];
STAssertEqualObjects(CCMFixedBuild, [userInfo objectForKey:@"buildResult"], @"Should have set correct build result.");
}
- (void)testCreatesStillFailingBuildCompleteNotification
{
NSDictionary *pi1 = [self createProjectInfoWithActivity:CCMBuildingActivity lastBuildStatus:CCMFailedStatus];
NSDictionary *pi2 = [self createProjectInfoWithActivity:CCMSleepingActivity lastBuildStatus:CCMFailedStatus];
NSNotification *notification = [factory buildCompleteNotificationForOldProjectInfo:pi1 andNewProjectInfo:pi2];
NSDictionary *userInfo = [notification userInfo];
STAssertEqualObjects(CCMStillFailingBuild, [userInfo objectForKey:@"buildResult"], @"Should have set correct build result.");
}
- (void)testCreatesBrokenBuildCompletionNotificationEvenIfBuildWasMissed
{
NSDictionary *pi1 = [self createProjectInfoWithActivity:CCMSleepingActivity lastBuildStatus:CCMSuccessStatus];
NSDictionary *pi2 = [self createProjectInfoWithActivity:CCMSleepingActivity lastBuildStatus:CCMFailedStatus];
NSNotification *notification = [factory buildCompleteNotificationForOldProjectInfo:pi1 andNewProjectInfo:pi2];
NSDictionary *userInfo = [notification userInfo];
STAssertEqualObjects(CCMBrokenBuild, [userInfo objectForKey:@"buildResult"], @"Should have set correct build result.");
}
- (void)testCreatesFixedBuildCompletionNotificationEvenIfBuildWasMissed
{
NSDictionary *pi1 = [self createProjectInfoWithActivity:CCMSleepingActivity lastBuildStatus:CCMFailedStatus];
NSDictionary *pi2 = [self createProjectInfoWithActivity:CCMSleepingActivity lastBuildStatus:CCMSuccessStatus];
NSNotification *notification = [factory buildCompleteNotificationForOldProjectInfo:pi1 andNewProjectInfo:pi2];
NSDictionary *userInfo = [notification userInfo];
STAssertEqualObjects(CCMFixedBuild, [userInfo objectForKey:@"buildResult"], @"Should have set correct build result.");
}
@end
Jump to Line
Something went wrong with that request. Please try again.