Skip to content

Commit

Permalink
test: Basic test for teams file
Browse files Browse the repository at this point in the history
  • Loading branch information
mvirgo committed Mar 12, 2023
1 parent dc7c30f commit 215be45
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 7 deletions.
File renamed without changes.
51 changes: 51 additions & 0 deletions foam-madness-tests/foam_madness_teams_file_test.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// foam_madness_team_file_test.swift
// foam-madness-tests
//
// Created by Michael Virgo on 3/11/23.
// Copyright © 2023 mvirgo. All rights reserved.
//

import XCTest

final class foam_madness_teams_file_test: XCTestCase {
var teamsDict = NSDictionary()

override func setUpWithError() throws {
loadTeams()
}

override func tearDownWithError() throws {}

func loadTeams() {
let path = Bundle.main.path(forResource: "teams", ofType: "plist")!
teamsDict = NSDictionary(contentsOfFile: path)!
}

func testEachTeamHasAbbreviationAndName() throws {
for team in teamsDict.allKeys {
let teamDict = teamsDict.value(forKey: team as! String) as! NSDictionary
let abbreviation = teamDict.value(forKey: "abbreviation") as? String
let name = teamDict.value(forKey: "name") as? String

if ((abbreviation ?? "").isEmpty) {
XCTFail("A team was missing an abbreviation")
}
if ((name ?? "").isEmpty) {
XCTFail("A team was missing a name")
}
}
}

func testAllTeamsHaveDistinctNames() throws {
// Abbreviations can overlap, but team names should not
var teamNamesSet = Set<String>()
for team in teamsDict.allKeys {
let teamDict = teamsDict.value(forKey: team as! String) as! NSDictionary
teamNamesSet.insert(teamDict.value(forKey: "name") as! String)
}
if (teamNamesSet.count != teamsDict.count) {
XCTFail("Not all team names are unique")
}
}
}
12 changes: 8 additions & 4 deletions foam-madness.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
7AF31A862431267400DF1605 /* GameHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF31A852431267400DF1605 /* GameHelper.swift */; };
D14C59E927DED2FE001378F1 /* mensBracket2022.plist in Resources */ = {isa = PBXBuildFile; fileRef = D14C59E827DED2FE001378F1 /* mensBracket2022.plist */; };
D14C59EB27DED30F001378F1 /* womensBracket2022.plist in Resources */ = {isa = PBXBuildFile; fileRef = D14C59EA27DED30F001378F1 /* womensBracket2022.plist */; };
D1A67BE629BD48E200E1D55B /* foam_madness_tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1A67BE529BD48E200E1D55B /* foam_madness_tests.swift */; };
D1A67BE629BD48E200E1D55B /* foam_madness_bracket_file_tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1A67BE529BD48E200E1D55B /* foam_madness_bracket_file_tests.swift */; };
D1A67BED29BD631D00E1D55B /* foam_madness_probability_file_test.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1A67BEC29BD631D00E1D55B /* foam_madness_probability_file_test.swift */; };
D1A67BEF29BD6E4D00E1D55B /* foam_madness_teams_file_test.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1A67BEE29BD6E4D00E1D55B /* foam_madness_teams_file_test.swift */; };
D1E16E1128334BB0007280EC /* bracketIndex.plist in Resources */ = {isa = PBXBuildFile; fileRef = D1E16E1028334BB0007280EC /* bracketIndex.plist */; };
D1E16E1C283354B0007280EC /* womensBracket2019.plist in Resources */ = {isa = PBXBuildFile; fileRef = D1E16E12283354B0007280EC /* womensBracket2019.plist */; };
D1E16E1D283354B0007280EC /* mensBracket2016.plist in Resources */ = {isa = PBXBuildFile; fileRef = D1E16E13283354B0007280EC /* mensBracket2016.plist */; };
Expand Down Expand Up @@ -112,8 +113,9 @@
D14C59E827DED2FE001378F1 /* mensBracket2022.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = mensBracket2022.plist; sourceTree = "<group>"; };
D14C59EA27DED30F001378F1 /* womensBracket2022.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = womensBracket2022.plist; sourceTree = "<group>"; };
D1A67BE329BD48E200E1D55B /* foam-madness-tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "foam-madness-tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
D1A67BE529BD48E200E1D55B /* foam_madness_tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = foam_madness_tests.swift; sourceTree = "<group>"; };
D1A67BE529BD48E200E1D55B /* foam_madness_bracket_file_tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = foam_madness_bracket_file_tests.swift; sourceTree = "<group>"; };
D1A67BEC29BD631D00E1D55B /* foam_madness_probability_file_test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = foam_madness_probability_file_test.swift; sourceTree = "<group>"; };
D1A67BEE29BD6E4D00E1D55B /* foam_madness_teams_file_test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = foam_madness_teams_file_test.swift; sourceTree = "<group>"; };
D1E16E1028334BB0007280EC /* bracketIndex.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = bracketIndex.plist; sourceTree = "<group>"; };
D1E16E12283354B0007280EC /* womensBracket2019.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = womensBracket2019.plist; sourceTree = "<group>"; };
D1E16E13283354B0007280EC /* mensBracket2016.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = mensBracket2016.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -286,8 +288,9 @@
D1A67BE429BD48E200E1D55B /* foam-madness-tests */ = {
isa = PBXGroup;
children = (
D1A67BEE29BD6E4D00E1D55B /* foam_madness_teams_file_test.swift */,
D1A67BEC29BD631D00E1D55B /* foam_madness_probability_file_test.swift */,
D1A67BE529BD48E200E1D55B /* foam_madness_tests.swift */,
D1A67BE529BD48E200E1D55B /* foam_madness_bracket_file_tests.swift */,
);
path = "foam-madness-tests";
sourceTree = "<group>";
Expand Down Expand Up @@ -445,8 +448,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D1A67BEF29BD6E4D00E1D55B /* foam_madness_teams_file_test.swift in Sources */,
D1A67BED29BD631D00E1D55B /* foam_madness_probability_file_test.swift in Sources */,
D1A67BE629BD48E200E1D55B /* foam_madness_tests.swift in Sources */,
D1A67BE629BD48E200E1D55B /* foam_madness_bracket_file_tests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
6 changes: 3 additions & 3 deletions foam-madness/teams.plist
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@
<key>abbreviation</key>
<string>MSMU</string>
<key>name</key>
<string>Mount St. Mary's</string>
<string>Mount St. Mary&apos;s</string>
</dict>
<key>182</key>
<dict>
Expand Down Expand Up @@ -889,7 +889,7 @@
<key>abbreviation</key>
<string>SJU</string>
<key>name</key>
<string>St Joseph's</string>
<string>St Joseph&apos;s</string>
</dict>
<key>212</key>
<dict>
Expand All @@ -903,7 +903,7 @@
<key>abbreviation</key>
<string>SPU</string>
<key>name</key>
<string>St Peter's</string>
<string>St Peter&apos;s</string>
</dict>
<key>214</key>
<dict>
Expand Down

0 comments on commit 215be45

Please sign in to comment.