diff --git a/Attributed.xcodeproj/project.pbxproj b/Attributed.xcodeproj/project.pbxproj index edbd115..8f80a5c 100644 --- a/Attributed.xcodeproj/project.pbxproj +++ b/Attributed.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + AA28CE69206A0D5F0025AA29 /* AttributedPublicTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA28CE68206A0D5F0025AA29 /* AttributedPublicTests.swift */; }; AA3150381EA4A57300A86368 /* Attributed.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA3150371EA4A57300A86368 /* Attributed.swift */; }; AA4B73E11E0B798C004C6947 /* StringExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA4B73E01E0B798C004C6947 /* StringExtensionTests.swift */; }; AABEF4EC1E98F532003260B7 /* NSString+Attributed.swift in Sources */ = {isa = PBXBuildFile; fileRef = AABEF4EB1E98F532003260B7 /* NSString+Attributed.swift */; }; @@ -29,6 +30,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + AA28CE68206A0D5F0025AA29 /* AttributedPublicTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedPublicTests.swift; sourceTree = ""; }; AA3150371EA4A57300A86368 /* Attributed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Attributed.swift; sourceTree = ""; }; AA4B73E01E0B798C004C6947 /* StringExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtensionTests.swift; sourceTree = ""; }; AABEF4EB1E98F532003260B7 /* NSString+Attributed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSString+Attributed.swift"; sourceTree = ""; }; @@ -129,9 +131,10 @@ AAEE627A1DF8F3690079C70C /* AttributedTests */ = { isa = PBXGroup; children = ( - AABEF4F21E98F73F003260B7 /* Supporting Files */, + AA28CE68206A0D5F0025AA29 /* AttributedPublicTests.swift */, AAE1A2761E01537500610C40 /* AttributesTests.swift */, AA4B73E01E0B798C004C6947 /* StringExtensionTests.swift */, + AABEF4F21E98F73F003260B7 /* Supporting Files */, ); path = AttributedTests; sourceTree = ""; @@ -261,6 +264,7 @@ buildActionMask = 2147483647; files = ( AA4B73E11E0B798C004C6947 /* StringExtensionTests.swift in Sources */, + AA28CE69206A0D5F0025AA29 /* AttributedPublicTests.swift in Sources */, AAE1A2771E01537500610C40 /* AttributesTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Attributed/Attributes.swift b/Attributed/Attributes.swift index a901f68..89913ec 100644 --- a/Attributed/Attributes.swift +++ b/Attributed/Attributes.swift @@ -26,7 +26,7 @@ import Foundation public struct Attributes { - let dictionary: [NSAttributedStringKey: Any] + public let dictionary: [NSAttributedStringKey: Any] public init() { dictionary = [:] diff --git a/AttributedTests/AttributedPublicTests.swift b/AttributedTests/AttributedPublicTests.swift new file mode 100644 index 0000000..dcbb6fc --- /dev/null +++ b/AttributedTests/AttributedPublicTests.swift @@ -0,0 +1,40 @@ +// +// AttributedPublicTests.swift +// +// Copyright (c) 2016-2018 Nicholas Maccharoli +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +import XCTest + +// DO NOT USE `@testable import` +// The tests in this file are checking the behaviour from the viewpoint of a normal client of this library +import Attributed + +class AttributedPublicTests: XCTestCase { + func testAttributesDictionary() { + let testAttributes = Attributes() + .font(.systemFont(ofSize: 12.0)) + .background(color: .green) + + let testResult = testAttributes.dictionary.keys.count == 2 + + XCTAssert(testResult, "Dictionary is not accessible") + } +}