public void TestSetup()
 {
     details = new EngageAuthenticationDetails();
 }
        public static EngageAuthenticationDetails FromXElement(XElement xElement)
        {
            var details = new EngageAuthenticationDetails();

            foreach (var element in xElement.Element("profile").Elements())
            {
                var elementLocalName = element.Name.LocalName;
                if (elementLocalName == "name")
                {
                    details.AssignName(EngageName.FromXElement(element));
                }
                else if (elementLocalName == "address")
                {
                    details.AssignAddress(EngageAddress.FromXElement(element));
                }
                else
                {
                    details.AddProperty(elementLocalName, element.Value);
                }
            }

            if(details.Name == null)
                details.AssignName(new EngageName());

            if(details.Address == null)
                details.AssignAddress(new EngageAddress());

            return details;
        }
        /// <summary>
        /// Use this method to map the openId identifier to something in your local domain. 
        /// It is possible that you may have already mapped this user, which you can 
        /// confirm by checking the LocalKey property of the AuthenticationDetails.
        /// </summary>
        private static string GetLocalKey(EngageAuthenticationDetails authenticationDetails)
        {
            if (string.IsNullOrEmpty(authenticationDetails.LocalKey))
            {

                throw new Exception("Once you have set your local domain mapping functionality, this exception can then be removed.");
                //TODO: Map the openId identifier to your local domain
                //TODO: This would also be a great place to interrogate the returned details - name, email etc.
                return "looked_up_local_key";
            }

            // previously mapped
            return authenticationDetails.LocalKey;
        }