use super::*;
use crate::inspect::smp::services::SmpSavePlacedStructureNonzeroCompanionNamePairSummaryEntry;

#[test]
fn summarizes_nonzero_companion_building_family_overlaps() {
    let overlaps =
        summarize_peer_site_selector_candidate_saved_nonzero_companion_building_family_overlaps(&[
            SmpSavePlacedStructureNonzeroCompanionNamePairSummaryEntry {
                companion_byte_hex: "0x01".to_string(),
                primary_name: "TextileMill".to_string(),
                secondary_name: "TextileMill".to_string(),
                count: 9,
            },
            SmpSavePlacedStructureNonzeroCompanionNamePairSummaryEntry {
                companion_byte_hex: "0x01".to_string(),
                primary_name: "Toolndie".to_string(),
                secondary_name: "Toolndie".to_string(),
                count: 2,
            },
            SmpSavePlacedStructureNonzeroCompanionNamePairSummaryEntry {
                companion_byte_hex: "0x01".to_string(),
                primary_name: "MunitionsFactory".to_string(),
                secondary_name: "MunitionsFactory".to_string(),
                count: 1,
            },
        ]);

    assert_eq!(overlaps.len(), 2);
    assert_eq!(overlaps[0].primary_name, "TextileMill");
    assert!(overlaps[0].primary_matches_nonzero_stock_building_header_family);
    assert!(overlaps[0].secondary_matches_nonzero_stock_building_header_family);
    assert_eq!(overlaps[1].primary_name, "Toolndie");
    assert!(overlaps[1].primary_matches_nonzero_stock_building_header_family);
    assert!(overlaps[1].secondary_matches_nonzero_stock_building_header_family);
}

#[test]
fn summarizes_nonzero_companion_building_family_residues() {
    let residues =
        summarize_peer_site_selector_candidate_saved_nonzero_companion_building_family_residues(&[
            SmpSavePlacedStructureNonzeroCompanionNamePairSummaryEntry {
                companion_byte_hex: "0x01".to_string(),
                primary_name: "TextileMill".to_string(),
                secondary_name: "TextileMill".to_string(),
                count: 9,
            },
            SmpSavePlacedStructureNonzeroCompanionNamePairSummaryEntry {
                companion_byte_hex: "0x01".to_string(),
                primary_name: "MunitionsFactory".to_string(),
                secondary_name: "MunitionsFactory".to_string(),
                count: 1,
            },
        ]);

    assert_eq!(residues.len(), 1);
    assert_eq!(residues[0].primary_name, "MunitionsFactory");
    assert_eq!(residues[0].secondary_name, "MunitionsFactory");
    assert_eq!(residues[0].companion_byte_hex, "0x01");
}
