import SwiftLintCore

internal struct TestCaseAccessibilityRuleExamples {
    static let nonTriggeringExamples = #examples([
        // Valid XCTestCase class

        "let foo: String?",
        """
        let foo: String?

        class FooTests: XCTestCase {
            static let allTests: [String] = []

            private let foo: String {
                let nestedMember = "hi"
                return nestedMember
            }

            override static func setUp() {}

            override func setUp() {}

            override func setUpWithError() throws {}

            override static func tearDown() {}

            override func tearDown() {}

            override func tearDownWithError() {}

            override func someFutureXCTestFunction() {
                super.someFutureXCTestFunction()
            }

            func testFoo() {
                XCTAssertTrue(true)
            }

            func testBar() {
                func nestedFunc() {}
            }

            private someFunc(hasParam: Bool) {}
        }
        """,

        """
        class FooTests: XCTestCase {
            private struct MockSomething: Something {}
        }
        """,

        """
        class FooTests: XCTestCase {
            override init() {
                super.init()
                let foo = 1
                var bar = 2
            }
        }
        """,

        """
        class FooTests: XCTestCase {
            func allowedPrefixTestFoo() {}
        }
        """.asExample(configuration: ["allowed_prefixes": ["allowedPrefix"]]),

        // Not an XCTestCase class

        """
        class Foobar {
            func setUp() {}

            func tearDown() {}

            func testFoo() {}
        }
        """,
    ])

    static let triggeringExamples = #examples([
        """
        class FooTests: XCTestCase {
            ↓typealias Bar = Foo.Bar

            ↓var foo: String?
            ↓let bar: String?

            ↓static func foo() {}

            ↓func setUp(withParam: String) {}

            ↓func foobar() {}

            ↓func not_testBar() {}

            ↓enum Nested {}

            ↓static func testFoo() {}

            ↓static func allTests() {}

            ↓func testFoo(hasParam: Bool) {}
        }

        final class BarTests: XCTestCase {
            ↓class Nested {}
        }
        """,
    ])

    static let corrections = #corrections([
        """
        class TotoTests: XCTestCase {
            ↓var foo: Bar?

            ↓struct Baz {}

            override func setUp() {}

            override func tearDown() {}

            func testFoo() {}

            func testBar() {}

            ↓func helperFunction() {}
        }
        """:
        """
        class TotoTests: XCTestCase {
            private var foo: Bar?

            private struct Baz {}

            override func setUp() {}

            override func tearDown() {}

            func testFoo() {}

            func testBar() {}

            private func helperFunction() {}
        }
        """,
    ])
}
