Browse Source

IOSAD-191 Move pEpMessageWithAllFieldsFilled to PEPTypesTestUtil.

IOSAD-191
David Alarcon 1 year ago
parent
commit
674235538e
3 changed files with 59 additions and 57 deletions
  1. +18
    -56
      PEPObjCAdapterTypesTests_iOS/PEPMessage+SecureCodingTest.m
  2. +2
    -1
      PEPObjCAdapterTypesTests_iOS/TestUtils/PEPTypesTestUtil.h
  3. +39
    -0
      PEPObjCAdapterTypesTests_iOS/TestUtils/PEPTypesTestUtil.m

+ 18
- 56
PEPObjCAdapterTypesTests_iOS/PEPMessage+SecureCodingTest.m View File

@ -31,126 +31,126 @@
}
- (void)testMessageMessageID {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.messageID, unarchivedTestee.messageID);
}
- (void)testMessageFrom {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.from, unarchivedTestee.from);
}
- (void)testMessageTo {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.to, unarchivedTestee.to);
}
- (void)testMessageCC {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.cc, unarchivedTestee.cc);
}
- (void)testMessageBCC {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.bcc, unarchivedTestee.bcc);
}
- (void)testMessageShortMessage {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.shortMessage, unarchivedTestee.shortMessage);
}
- (void)testMessageLongMessage {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.longMessage, unarchivedTestee.longMessage);
}
- (void)testMessageLongMessageFormatted {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.longMessageFormatted, unarchivedTestee.longMessageFormatted);
}
- (void)testMessageReplyTo {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.replyTo, unarchivedTestee.replyTo);
}
- (void)testMessageInReplyTo {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.inReplyTo, unarchivedTestee.inReplyTo);
}
- (void)testMessageReferences {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.references, unarchivedTestee.references);
}
- (void)testMessageSentDate {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.sentDate, unarchivedTestee.sentDate);
}
- (void)testMessageReceivedDate {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.receivedDate, unarchivedTestee.receivedDate);
}
- (void)testMessageAttachments {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.attachments, unarchivedTestee.attachments);
}
- (void)testMessageOptionalFields {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.optionalFields, unarchivedTestee.optionalFields);
}
- (void)testMessageKeywords {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.keywords, unarchivedTestee.keywords);
}
- (void)testMessageReceivedBy {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.receivedBy, unarchivedTestee.receivedBy);
}
- (void)testMessageDirection {
PEPMessage *testee = [self messageWithAllFieldsFilled];
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqual(testee.direction, unarchivedTestee.direction);
@ -173,44 +173,6 @@
return unarchivedMessage;
}
- (PEPMessage *)messageWithAllFieldsFilled {
PEPMessage *message = [PEPMessage new];
PEPIdentity *identity = [PEPTypesTestUtil pEpIdentityWithAllFieldsFilled];
PEPAttachment *attachment = [PEPTypesTestUtil pEpAttachmentWithAllFieldsFilled];
message.messageID = [NSString stringWithFormat: @"19980506192030.26456.%@", identity.address];
message.from = identity;
message.to = @[identity];
message.cc = @[identity];
message.bcc = @[identity];
message.shortMessage = @"shortMessage";
message.longMessage = @"longMessage";
message.longMessageFormatted = @"longMessageFormatted";
message.replyTo = @[identity];
message.inReplyTo = @[[NSString stringWithFormat: @"19980507220459.5655.%@", identity.address]];
message.references = @[[NSString stringWithFormat:
@"19980509035615.40087.%@",
identity.address]];
NSDate *yesterday = [NSCalendar.currentCalendar dateByAddingUnit:NSCalendarUnitDay
value:-1 toDate:[NSDate now]
options:NSCalendarWrapComponents];
message.sentDate = yesterday;
message.receivedDate = [NSDate now];
message.attachments = @[attachment];
message.optionalFields = @[@"optionalField"];
message.keywords = @[@"keyword"];
message.receivedBy = identity;
message.direction = PEPMsgDirectionIncoming;
return message;
}
@end
@implementation PEPAttachment (Equatable)


+ 2
- 1
PEPObjCAdapterTypesTests_iOS/TestUtils/PEPTypesTestUtil.h View File

@ -10,12 +10,13 @@
NS_ASSUME_NONNULL_BEGIN
@class PEPIdentity, PEPAttachment, PEPLanguage;
@class PEPIdentity, PEPAttachment, PEPLanguage, PEPMessage;
@interface PEPTypesTestUtil : NSObject
+ (PEPIdentity *)pEpIdentityWithAllFieldsFilled;
+ (PEPAttachment *)pEpAttachmentWithAllFieldsFilled;
+ (PEPLanguage *)pEpLanguageWithAllFieldsFilled;
+ (PEPMessage *)pEpMessageWithAllFieldsFilled;
@end


+ 39
- 0
PEPObjCAdapterTypesTests_iOS/TestUtils/PEPTypesTestUtil.m View File

@ -11,6 +11,7 @@
#import "PEPIdentity.h"
#import "PEPAttachment.h"
#import "PEPLanguage.h"
#import "PEPMessage.h"
@implementation PEPTypesTestUtil
@ -50,4 +51,42 @@
return language;
}
+ (PEPMessage *)pEpMessageWithAllFieldsFilled {
PEPMessage *message = [PEPMessage new];
PEPIdentity *identity = [PEPTypesTestUtil pEpIdentityWithAllFieldsFilled];
PEPAttachment *attachment = [PEPTypesTestUtil pEpAttachmentWithAllFieldsFilled];
message.messageID = [NSString stringWithFormat: @"19980506192030.26456.%@", identity.address];
message.from = identity;
message.to = @[identity];
message.cc = @[identity];
message.bcc = @[identity];
message.shortMessage = @"shortMessage";
message.longMessage = @"longMessage";
message.longMessageFormatted = @"longMessageFormatted";
message.replyTo = @[identity];
message.inReplyTo = @[[NSString stringWithFormat: @"19980507220459.5655.%@", identity.address]];
message.references = @[[NSString stringWithFormat:
@"19980509035615.40087.%@",
identity.address]];
NSDate *yesterday = [NSCalendar.currentCalendar dateByAddingUnit:NSCalendarUnitDay
value:-1 toDate:[NSDate now]
options:NSCalendarWrapComponents];
message.sentDate = yesterday;
message.receivedDate = [NSDate now];
message.attachments = @[attachment];
message.optionalFields = @[@"optionalField"];
message.keywords = @[@"keyword"];
message.receivedBy = identity;
message.direction = PEPMsgDirectionIncoming;
return message;
}
@end

Loading…
Cancel
Save