public void EmailValidationShouldAcceptOnlyValidEmails()
        {
            Dictionary <string, bool> ValidEmailDictionary = new Dictionary <string, bool>()
            {
                { "*****@*****.**", true },
                { "*****@*****.**", true },
                { "*****@*****.**", true },
                { "*****@*****.**", false },
                { "[email protected]", true },
                { "js#[email protected]", true },
                { "j_9@[129.126.118.1]", true },
                { "*****@*****.**", false },
                { "js*@proseware.com", false },
                { "*****@*****.**", false },
                { "[email protected]", true },
                { "*****@*****.**", true },
                { "\"j\\\"s\\\"\"@proseware.com", true },
                { "js@contoso.中国", true }
            };

            foreach (KeyValuePair <string, bool> validEmail in ValidEmailDictionary)
            {
                bool isValid = DataValidationHelper.IsValidEmailAddress(validEmail.Key);
                Assert.That(isValid, Is.EqualTo(validEmail.Value), "Email Address : " + validEmail.Key + " Failed");
            }
        }
        /// <summary>
        /// This method needs fixing, removing these "if" statements would be nice.
        /// </summary>
        /// <param name="res"></param>
        /// <returns>
        /// </returns>
        public override Validation Validate(Reservation res)
        {
            Validation validate = new Validation();


            if (res == null)
            {
                validate.AddError("reservation", "reservation can not be null");
            }
            else
            {
                if (res.InventoryID == null)
                {
                    validate.AddError("reservation.InventoryID", "InventoryID can not be null");
                }
                else if (res.Inventory == null)
                {
                    Inventory i = InventoryRepository.GetById(res.InventoryID.Value);
                    if (i != null)
                    {
                        res.Inventory = i;
                    }
                    else
                    {
                        validate.AddError("reservation.Inventory", "Inventory not found");
                    }
                }


                if (String.IsNullOrEmpty(res.CustomerNameFirst))
                {
                    validate.AddError("reservation.CustomerNameFirst", "CustomerNameFirst can not be null");
                }

                if (String.IsNullOrEmpty(res.CustomerNameLast))
                {
                    validate.AddError("reservation.CustomerNameLast", "CustomerNameLast can not be null");
                }

                if (String.IsNullOrEmpty(res.CustomerEmail))
                {
                    validate.AddError("reservation.CustomerEmail", "CustomerEmail can not be null");
                }

                if (String.IsNullOrEmpty(res.CustomerPhone))
                {
                    validate.AddError("reservation.CustomerPhone", "CustomerPhone can not be null");
                }

                if (res.CreationDate == null)
                {
                    validate.AddError("reservation.CreationDate", "CreationDate can not be null");
                }

                if (res.StartDate == null)
                {
                    validate.AddError("reservation.StartDate", "StartDate can not be null");
                }

                if (res.EndDate == null)
                {
                    validate.AddError("reservation.EndDate", "EndDate can not be null");
                }

                if (res.StartDate != null && res.EndDate != null && res.StartDate > res.EndDate)
                {
                    validate.AddError("reservation.StartDate", "StartDate must be before EndDate");
                    validate.AddError("reservation.EndDate", "EndDate must be after StartDate");
                }
                if (res.Inventory?.Status?.IsDisabling.Value == true)
                {
                    validate.AddError("reservation.Inventory", "Inventory status is Disabled");
                }


                if (DataValidationHelper.IsValidEmailAddress(res.CustomerEmail) == false)
                {
                    validate.AddError("reservation.CustomerEmail", "Invalid Email");
                }
                if (DataValidationHelper.IsValidPhoneNumber(res.CustomerPhone) == false)
                {
                    validate.AddError("reservation.CustomerPhone", "Invalid Phone Number");
                }
            }
            return(validate);
        }