Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding tests for message and put some parts to private API.

  • Loading branch information...
commit 4ae0d03b51a8f2b0dcfc4438b84f90c70d560d13 1 parent 16d9bc4
@pk authored
View
2  PKWebSocket/PKWebSocketMessage.h
@@ -22,8 +22,6 @@ typedef enum {
+ (id)messageWithData:(NSData *)data;
+ (id)messageWithString:(NSString *)string;
-- (id)initWithContent:(id)content type:(PKWebSocketMessageType)type;
-
- (BOOL)isBinary;
@end
View
3  PKWebSocket/PKWebSocketMessage.m
@@ -8,6 +8,9 @@
#import "PKWebSocketMessage.h"
+@interface PKWebSocketMessage ()
+@end
+
@implementation PKWebSocketMessage
@synthesize data = _data;
View
41 PKWebSocketTests/PKWebSocketMessageTests.m
@@ -0,0 +1,41 @@
+//
+// PKWebSocketMessageTests.m
+// PKWebSocketMessageTests
+//
+// Created by Pavel Kunc on 16/04/2012.
+// Copyright (c) 2012 Pavel Kunc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <SenTestingKit/SenTestingKit.h>
+#import "PKWebSocketMessage.h"
+
+@interface PKWebSocketMessageTests : SenTestCase
+@end
+
+@implementation PKWebSocketMessageTests
+
+- (void)setUp {
+ [super setUp];
+}
+
+- (void)tearDown {
+ [super tearDown];
+}
+
+- (void)testMessageWithDataCreateBinaryMessage {
+ NSData *data = [NSData dataWithBytes:"\x48\x65\x6C\x6C\x6F" length:5];
+ PKWebSocketMessage *msg = [PKWebSocketMessage messageWithData:data];
+ STAssertTrue([msg isBinary], @"Must be binary");
+ STAssertTrue([msg.data isEqualToData:data], @"What you put in you get back");
+ STAssertNil(msg.string, @"No string can be set");
+}
+
+- (void)testMessageWithDataCreateStringMessage {
+ PKWebSocketMessage *msg = [PKWebSocketMessage messageWithString:@"foo-bar"];
+ STAssertFalse([msg isBinary], @"Must be string");
+ STAssertTrue([msg.string isEqualToString:@"foo-bar"], @"What you put in you get back.");
+ STAssertNil(msg.data, @"No data can be set");
+}
+
+@end
Please sign in to comment.
Something went wrong with that request. Please try again.