-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 8855d1b.
- Loading branch information
Showing
206 changed files
with
17,777 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Tests/AnalyticsTests/ComScore/ComScoreHitExpectation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// Copyright (c) SRG SSR. All rights reserved. | ||
// | ||
// License information is available from the LICENSE file. | ||
// | ||
|
||
import PillarboxAnalytics | ||
|
||
/// Describes a comScore stream hit expectation. | ||
struct ComScoreHitExpectation { | ||
private let name: ComScoreHit.Name | ||
private let evaluate: (ComScoreLabels) -> Void | ||
|
||
fileprivate init(name: ComScoreHit.Name, evaluate: @escaping (ComScoreLabels) -> Void) { | ||
self.name = name | ||
self.evaluate = evaluate | ||
} | ||
|
||
static func match(hit: ComScoreHit, with expectation: Self) -> Bool { | ||
guard hit.name == expectation.name else { return false } | ||
expectation.evaluate(hit.labels) | ||
return true | ||
} | ||
} | ||
|
||
extension ComScoreHitExpectation: CustomDebugStringConvertible { | ||
var debugDescription: String { | ||
name.rawValue | ||
} | ||
} | ||
|
||
extension ComScoreTestCase { | ||
func play(evaluate: @escaping (ComScoreLabels) -> Void = { _ in }) -> ComScoreHitExpectation { | ||
ComScoreHitExpectation(name: .play, evaluate: evaluate) | ||
} | ||
|
||
func playrt(evaluate: @escaping (ComScoreLabels) -> Void = { _ in }) -> ComScoreHitExpectation { | ||
ComScoreHitExpectation(name: .playrt, evaluate: evaluate) | ||
} | ||
|
||
func pause(evaluate: @escaping (ComScoreLabels) -> Void = { _ in }) -> ComScoreHitExpectation { | ||
ComScoreHitExpectation(name: .pause, evaluate: evaluate) | ||
} | ||
|
||
func end(evaluate: @escaping (ComScoreLabels) -> Void = { _ in }) -> ComScoreHitExpectation { | ||
ComScoreHitExpectation(name: .end, evaluate: evaluate) | ||
} | ||
|
||
func view(evaluate: @escaping (ComScoreLabels) -> Void = { _ in }) -> ComScoreHitExpectation { | ||
ComScoreHitExpectation(name: .view, evaluate: evaluate) | ||
} | ||
} |
Oops, something went wrong.