// // Plant+TestFixtures.swift // PlantGuideTests // // Test fixtures for Plant entity - provides factory methods for creating // test instances with sensible defaults. // import Foundation @testable import PlantGuide // MARK: - Plant Test Fixtures extension Plant { // MARK: - Factory Methods /// Creates a mock plant with default values for testing /// - Parameters: /// - id: The plant's unique identifier. Defaults to a new UUID. /// - scientificName: Scientific name. Defaults to "Monstera deliciosa". /// - commonNames: Array of common names. Defaults to ["Swiss Cheese Plant"]. /// - family: Botanical family. Defaults to "Araceae". /// - genus: Botanical genus. Defaults to "Monstera". /// - imageURLs: Remote image URLs. Defaults to empty. /// - dateIdentified: When plant was identified. Defaults to current date. /// - identificationSource: Source of identification. Defaults to .onDeviceML. /// - localImagePaths: Local storage paths. Defaults to empty. /// - dateAdded: When added to collection. Defaults to nil. /// - confidenceScore: Identification confidence. Defaults to 0.95. /// - notes: User notes. Defaults to nil. /// - isFavorite: Favorite status. Defaults to false. /// - customName: User-assigned name. Defaults to nil. /// - location: Plant location. Defaults to nil. /// - Returns: A configured Plant instance for testing static func mock( id: UUID = UUID(), scientificName: String = "Monstera deliciosa", commonNames: [String] = ["Swiss Cheese Plant"], family: String = "Araceae", genus: String = "Monstera", imageURLs: [URL] = [], dateIdentified: Date = Date(), identificationSource: IdentificationSource = .onDeviceML, localImagePaths: [String] = [], dateAdded: Date? = nil, confidenceScore: Double? = 0.95, notes: String? = nil, isFavorite: Bool = false, customName: String? = nil, location: String? = nil ) -> Plant { Plant( id: id, scientificName: scientificName, commonNames: commonNames, family: family, genus: genus, imageURLs: imageURLs, dateIdentified: dateIdentified, identificationSource: identificationSource, localImagePaths: localImagePaths, dateAdded: dateAdded, confidenceScore: confidenceScore, notes: notes, isFavorite: isFavorite, customName: customName, location: location ) } /// Creates a mock Monstera plant static func mockMonstera( id: UUID = UUID(), isFavorite: Bool = false ) -> Plant { mock( id: id, scientificName: "Monstera deliciosa", commonNames: ["Swiss Cheese Plant", "Monstera"], family: "Araceae", genus: "Monstera", isFavorite: isFavorite ) } /// Creates a mock Pothos plant static func mockPothos( id: UUID = UUID(), isFavorite: Bool = false ) -> Plant { mock( id: id, scientificName: "Epipremnum aureum", commonNames: ["Pothos", "Devil's Ivy", "Golden Pothos"], family: "Araceae", genus: "Epipremnum", isFavorite: isFavorite ) } /// Creates a mock Snake Plant static func mockSnakePlant( id: UUID = UUID(), isFavorite: Bool = false ) -> Plant { mock( id: id, scientificName: "Sansevieria trifasciata", commonNames: ["Snake Plant", "Mother-in-law's Tongue"], family: "Asparagaceae", genus: "Sansevieria", isFavorite: isFavorite ) } /// Creates a mock Peace Lily plant static func mockPeaceLily( id: UUID = UUID(), isFavorite: Bool = false ) -> Plant { mock( id: id, scientificName: "Spathiphyllum wallisii", commonNames: ["Peace Lily", "Spathe Flower"], family: "Araceae", genus: "Spathiphyllum", isFavorite: isFavorite ) } /// Creates a mock Fiddle Leaf Fig plant static func mockFiddleLeafFig( id: UUID = UUID(), isFavorite: Bool = false ) -> Plant { mock( id: id, scientificName: "Ficus lyrata", commonNames: ["Fiddle Leaf Fig", "Fiddle-leaf Fig"], family: "Moraceae", genus: "Ficus", isFavorite: isFavorite ) } /// Creates an array of mock plants for collection testing static func mockCollection(count: Int = 5) -> [Plant] { var plants: [Plant] = [] let generators: [() -> Plant] = [ { .mockMonstera() }, { .mockPothos() }, { .mockSnakePlant() }, { .mockPeaceLily() }, { .mockFiddleLeafFig() } ] for i in 0.. Plant { let imageURLs = (0.. Plant { let localPaths = (0.. Plant { mock( id: id, scientificName: "Monstera deliciosa", commonNames: ["Swiss Cheese Plant", "Monstera", "Split-leaf Philodendron"], family: "Araceae", genus: "Monstera", imageURLs: [URL(string: "https://example.com/monstera.jpg")!], dateIdentified: Date(), identificationSource: .plantNetAPI, localImagePaths: ["\(id.uuidString)/captured.jpg"], dateAdded: Date(), confidenceScore: 0.98, notes: "Needs regular watering and indirect light", isFavorite: true, customName: "My Beautiful Monstera", location: "Living room by the window" ) } }