Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various changes to the Article class #1865

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
51 changes: 51 additions & 0 deletions Vienna Tests/ArticleTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// VNAArticleTests.m
// Vienna
//
// Copyright © 2016 uk.co.opencommunity. All rights reserved.
//

@import XCTest;

#import "Article.h"
#import "Vienna_Tests-Swift.h"

static NSString * const guid = @"07f446d2-8d6b-4d99-b488-cebc9eac7c33";

@interface VNAArticleTests : XCTestCase

@property (nonatomic) Article *article;

@end

@implementation VNAArticleTests

- (void)setUp
{
self.article = [[Article alloc] initWithGUID:guid];
}

- (void)tearDown
{
self.article = nil;
}

- (void)testRandomCompatibilityKeyPath
{
NSString *randomArticleDataKeyPath = [@"articleData." stringByAppendingString:@"dummyProperty"];

XCTAssertThrowsSpecificNamed([self.article valueForKeyPath:randomArticleDataKeyPath],
NSException,
NSUndefinedKeyException);
}

- (void)testRandomKeyPath
{
NSString *randomKeyPath = @"dummyProperty";

XCTAssertThrowsSpecificNamed([self.article valueForKeyPath:randomKeyPath],
NSException,
NSUndefinedKeyException);
}

@end
62 changes: 32 additions & 30 deletions Vienna Tests/ArticleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,16 @@ class ArticleTests: XCTestCase {
var article: Article!
var articleConverter: WebKitArticleConverter!

override func setUpWithError() throws {
try super.setUpWithError()
// Put setup code here. This method is called before the invocation of each test method in the class.
override func setUp() {
self.article = Article(guid: guid)
self.articleConverter = WebKitArticleConverter()
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
override func tearDown() {
self.article = nil
try super.tearDownWithError()
}

// MARK: Article Tests
// MARK: - Article Tests

func testAccessInstanceVariablesDirectly() {
XCTAssertFalse(Article.accessInstanceVariablesDirectly)
Expand All @@ -64,24 +60,32 @@ class ArticleTests: XCTestCase {
// MARK: - Test custom setters

func testTitle() {
XCTAssertNil(self.article.title)

self.article.title = title

XCTAssertEqual(self.article.title, title)
}

func testAuthor() {
XCTAssertNil(self.article.author)

self.article.author = author

XCTAssertEqual(self.article.author, author)
}

func testLink() {
XCTAssertNil(self.article.link)

self.article.link = link

XCTAssertEqual(self.article.link, link)
}

func testLastUpdate() {
XCTAssertNil(self.article.lastUpdate)

let date = Date()

self.article.lastUpdate = date
Expand All @@ -90,6 +94,8 @@ class ArticleTests: XCTestCase {
}

func testPublicationDate() {
XCTAssertNil(self.article.publicationDate)

let date = Date()

self.article.publicationDate = date
Expand All @@ -98,30 +104,35 @@ class ArticleTests: XCTestCase {
}

func testBody() {
XCTAssertNil(self.article.body)

self.article.body = body

XCTAssertEqual(self.article.body, body)
}

func testEnclosure() {
XCTAssertNil(self.article.enclosure)

self.article.enclosure = enclosure

XCTAssertEqual(self.article.enclosure, enclosure)
}

func testEnclosureRemoval() {
self.article.enclosure = nil

XCTAssertNil(self.article.enclosure)
}

func testHasEnclosure() {
XCTAssertFalse(self.article.hasEnclosure)

self.article.hasEnclosure = true

XCTAssert(self.article.hasEnclosure)
}

func testFolderId() {
XCTAssertEqual(self.article.folderId, -1)

let folderId = 111

self.article.folderId = folderId
Expand All @@ -130,12 +141,13 @@ class ArticleTests: XCTestCase {
}

func testGuid() {
self.article.guid = guid

// The GUID is set by the initializer.
XCTAssertEqual(self.article.guid, guid)
}

func testParentId() {
XCTAssertEqual(self.article.parentId, 0)

let parentId = 222

self.article.parentId = parentId
Expand All @@ -144,7 +156,9 @@ class ArticleTests: XCTestCase {
}

func testStatus() {
let status = ArticleStatus.new.rawValue
XCTAssertEqual(self.article.status, .empty)

let status = Article.Status.new

self.article.status = status

Expand All @@ -154,39 +168,39 @@ class ArticleTests: XCTestCase {
func testMarkRead() {
XCTAssertFalse(self.article.isRead)

self.article.markRead(true)
self.article.isRead = true

XCTAssert(self.article.isRead)
}

func testMarkRevised() {
XCTAssertFalse(self.article.isRevised)

self.article.markRevised(true)
self.article.isRevised = true

XCTAssert(self.article.isRevised)
}

func testMarkDeleted() {
XCTAssertFalse(self.article.isDeleted)

self.article.markDeleted(true)
self.article.isDeleted = true

XCTAssert(self.article.isDeleted)
}

func testMarkFlagged() {
XCTAssertFalse(self.article.isFlagged)

self.article.markFlagged(true)
self.article.isFlagged = true

XCTAssert(self.article.isFlagged)
}

func testMarkEnclosureDowloaded() {
XCTAssertFalse(self.article.enclosureDownloaded)

self.article.markEnclosureDownloaded(true)
self.article.enclosureDownloaded = true

XCTAssert(self.article.enclosureDownloaded)
}
Expand Down Expand Up @@ -235,18 +249,6 @@ class ArticleTests: XCTestCase {
XCTAssertEqual(self.article.value(forKeyPath: summaryKeyPath) as? String, summary)
}

// func testRandomCompatibilityKeyPath() {
// let randomArticleDataKeyPath = "articleData.dummyProperty"
//
// XCTAssertThrowsSpecificNamed(self.article.value(forKeyPath: randomArticleDataKeyPath), NSException, NSUndefinedKeyException);
// }

// func testRandomKeyPath() {
// let randomKeyPath = "dummyProperty"
//
// XCTAssertThrowsSpecificNamed(self.article.value(forKeyPath: randomKeyPath), NSException, NSUndefinedKeyException);
// }

func testDescription() {
let title = "Lorem ipsum dolor sit amet"

Expand Down
Loading