//! Method to convert Domain to fully qualified domain name

use crate::types::domain::Domain;

impl Domain {
    /// Converts the Domain to a fully qualified domain name (FQDN)
    ///
    /// # Returns
    ///
    /// Returns a String in the format "name.tld" (e.g., "example.com")
    ///
    /// # Examples
    ///
    /// ```
    /// use lazydomain::types::Domain;
    ///
    /// let domain = Domain::new("example", "com").unwrap();
    /// assert_eq!(domain.to_fqdn(), "example.com");
    /// ```
    pub fn to_fqdn(&self) -> String {
        format!("{}.{}", self.name, self.tld)
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_formats_fqdn_correctly() {
        let domain = Domain::new("example", "com").unwrap();
        assert_eq!(domain.to_fqdn(), "example.com");
    }

    #[test]
    fn test_formats_different_tlds() {
        let domain_io = Domain::new("myapp", "io").unwrap();
        assert_eq!(domain_io.to_fqdn(), "myapp.io");

        let domain_dev = Domain::new("test", "dev").unwrap();
        assert_eq!(domain_dev.to_fqdn(), "test.dev");
    }
}
