import SwiftLintCore

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

        """
        class TotoTests: XCTestCase {
            var foobar: Foobar?

            override func setUp() {
                super.setUp()
                foobar = Foobar()
            }

            override func setUpWithError() throws {
                foobar = nil
            }

            override func tearDown() {
                foobar = nil
                super.tearDown()
            }

            func testFoo() {
                XCTAssertTrue(foobar?.foo)
            }

            func testBar() {
                // comment...

                XCTAssertFalse(foobar?.bar)

                // comment...
            }

            func testBaz() {
                _ = 4 + 4
            }
        }
        """,

        // Not an XCTestCase class

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

            func tearDown() {}

            func testFoo() {}
        }
        """,

        // Methods with parameters

        """
        class TotoTests: XCTestCase {
            func setUp(with object: Foobar) {}

            func tearDown(object: Foobar) {}

            func testFoo(_ foo: Foobar) {}

            func testBar(bar: (String) -> Int) {}
        }
        """,

        // Asserts in one line

        """
        class TotoTests: XCTestCase {
            func testFoo() { XCTAssertTrue(foobar?.foo) }

            func testBar() { XCTAssertFalse(foobar?.bar) }
        }
        """,

        // Class/static variables

        """
        class TotoTests: XCTestCase {
            override class var runsForEachTargetApplicationUIConfiguration: Bool { true }

            static var allTests = [("testFoo", testFoo)]

            func testFoo() { XCTAssert(true) }
        }
        """,

        """
        extension C {
            override func foo(a: Int) {}
        }

        struct S {
            override func foo(a: Int) {}
        }

        enum E {
            override func foo(a: Int) {}
        }
        """.asExample(excludeFromDocumentation: true),
    ])

    static let triggeringExamples = #examples([
        // XCTestCase class with empty methods

        """
        class TotoTests: XCTestCase {
            override ↓func setUp() {
            }

            override ↓func tearDown() {

            }

            ↓func testFoo() {


            }

            ↓func testBar() {



            }

            func helperFunction() {
            }
        }
        """,

        """
        class TotoTests: XCTestCase {
            override ↓func setUp() {}

            override ↓func tearDown() {}

            ↓func testFoo() {}

            func helperFunction() {}
        }
        """,

        // XCTestCase class with comments (and blank lines)

        """
        class TotoTests: XCTestCase {
            override ↓func setUp() {
                // comment...
            }

            override ↓func tearDown() {
                // comment...
                // comment...
            }

            ↓func testFoo() {
                // comment...

                // comment...

                // comment...
            }

            ↓func testBar() {
                /*
                 * comment...
                 *
                 * comment...
                 *
                 * comment...
                 */
            }

            func helperFunction() {
            }
        }
        """,

        // Two XCTestCase classes on the same file

        """
        class FooTests: XCTestCase {
            override ↓func setUp() {}
        }

        class BarTests: XCTestCase {
            ↓func testFoo() {}
        }
        """,
    ])
}
