using System;
using System.Collections.Generic;

public enum ContType
{
    Email,
    PhoneCall,
    Meeting,
    FollowUp,
    Other
}

public enum SbFirmType
{
    LegalEntity,            // Юридическое лицо
    Branch,                 // Филиал
    RepresentativeOffice,   // Представительство
    Subsidiary,             // Дочернее предприятие
    Other                   // Другие типы
}

public class Contact
{
    public DateTime BeginDate { get; set; }
    public DateTime EndDate { get; set; }
    public string Description { get; set; }
    public string DataInfo { get; set; }
    public ContType Type { get; set; }

    public Contact(DateTime beginDate, DateTime endDate, string description, string dataInfo, ContType type)
    {
        BeginDate = beginDate;
        EndDate = endDate;
        Description = description;
        DataInfo = dataInfo;
        Type = type;
    }
}

public class SubFirm
{
    public string Name { get; set; }
    public string BossName { get; set; }
    public string OfficialBossName { get; set; }
    public string Phone { get; set; }
    public string Email { get; set; }
    public List<Contact> Contacts { get; set; }
    public SbFirmType Type { get; set; } // TODO: Define SbFirmType

    public SubFirm(string name, string bossName, string officialBossName, string phone, string email, SbFirmType type)
    {
        Name = name;
        BossName = bossName;
        OfficialBossName = officialBossName;
        Phone = phone;
        Email = email;
        Type = type;
        Contacts = new List<Contact>();
    }
}

public class Firm
{
    public string Name { get; set; }
    public string Country { get; set; }
    public string Region { get; set; }
    public string Town { get; set; }
    public string Street { get; set; }
    public string PostalIndex { get; set; }
    public DateTime DateOfEntry { get; set; }
    public string Email { get; set; }
    public string Website { get; set; }
    public List<SubFirm> SubFirms { get; set; }
    public Dictionary<string, string> UserFields { get; set; }

    public Firm(string name)
    {
        Name = name;
        SubFirms = new List<SubFirm>();
        UserFields = new Dictionary<string, string>();
    }

    public void AddSubFirm(SubFirm subFirm)
    {
        SubFirms.Add(subFirm);
    }

    public void AddContactToSubFirm(string subFirmName, Contact contact)
    {
        var subFirm = SubFirms.Find(sf => sf.Name == subFirmName);
        if (subFirm != null)
        {
            subFirm.Contacts.Add(contact);
        }
    }
}

public class FirmManager
{
    public Dictionary<string, string> UserFieldNames { get; set; }

    public FirmManager()
    {
        UserFieldNames = new Dictionary<string, string>
        {
            { "Field1", "Field 1" },
            { "Field2", "Field 2" },
            { "Field3", "Field 3" },
            { "Field4", "Field 4" },
            { "Field5", "Field 5" }
        };
    }

    public Firm CreateFirm(string name)
    {
        return new Firm(name);
    }

    public void SetUserFieldName(string key, string name)
    {
        if (UserFieldNames.ContainsKey(key))
        {
            UserFieldNames[key] = name;
        }
    }
}

напиши тесть для проверки AddContactToSubFirm