using AcmeCorp.DomainLibrary.AcmeEmployeeDomain;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NewEmployeeWFLibrary_Test.Helpers
{
    internal static class AcmeEmployeeAssert
    {
        internal static void AreEqualExceptForId(AcmeEmployee employee1, AcmeEmployee employee2)
        {
            CompareStringPropertyValues(employee1.FirstName, employee2.FirstName, "FirstName");
            CompareStringPropertyValues(employee1.LastName, employee2.LastName, "LastName");
            CompareStringPropertyValues(employee1.Email, employee2.Email, "Email");
        }

        internal static void AreEqual(AcmeEmployee employee1, AcmeEmployee employee2)
        {
            AcmeEmployeeAssert.AreEqualExceptForId(employee1, employee2);

            CompareStringPropertyValues(employee1.ID, employee2.ID, "ID");
        }

        private static void CompareStringPropertyValues(string value1, string value2, string propertyName)
        {
            if (value1.ToLower() != value2.ToLower())
            {
                string msg = "{0} properties are not the same. Expected:{1}, Got: {2}.";
                msg = string.Format(msg, propertyName, value1.ToLower(), value2.ToLower());
                throw new AssertFailedException(msg);
            }
        }
    }
}