public void GetCustomerProfileByAuthenticationTest_InvalidCredentials()
        {
            CustomerHPIDUtils custUtils = new CustomerHPIDUtils();

            GetProfileResponse response = custUtils.GetCustomerProfileByAuthentication(null, It.IsAny <bool>(), null, null, It.IsAny <APIMethods>());

            Assert.IsTrue(response.ErrorList.Count == 1);
            Assert.IsTrue(response.ErrorList.Contains(Faults.InvalidCredentials));
        }
        public void GetCustomerProfileByAuthenticationTest_HPIDInternalError()
        {
            CustomerHPIDUtils custUtils = new CustomerHPIDUtils();

            hpidUtilsMock.Setup(x => x.GetHPIDSessionToken(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <GetProfileResponse>(), It.IsAny <string>(), It.IsAny <int>())).
            Callback((int t, string u, string p, ResponseBase r, string c, int z) =>
            {
                r.ErrorList.Add(Faults.HPIDInternalError);
            });

            GetProfileResponse response = custUtils.GetCustomerProfileByAuthentication(null, It.IsAny <bool>(), "access", "url", It.IsAny <APIMethods>());

            Assert.IsTrue(response.ErrorList.Count == 1);
            Assert.IsTrue(response.ErrorList.Contains(Faults.HPIDInternalError));
        }
        public void GetCustomerProfileByAuthenticationTest_Success()
        {
            bool IsNewCustomer             = false;
            CustomerHPIDUtils custUtils    = new CustomerHPIDUtils();
            RoleUtils         rlUtils      = new RoleUtils();
            TokenDetails      sessionToken = new TokenDetails();

            sessionToken.AccessToken = "sessionToken";
            hpidUtilsMock.Setup(x => x.GetHPIDSessionToken(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <GetProfileResponse>(), It.IsAny <string>(), It.IsAny <int>())).Returns(sessionToken);
            hpidUtilsMock.Setup(x => x.GetIdsAndProfile(It.IsAny <CustomerIds>(), It.IsAny <string>(), It.IsAny <GetProfileResponse>())).
            Callback((CustomerIds i, string u, GetProfileResponse r) =>
            {
                i = new CustomerIds()
                {
                    HPIDid = "hpidid", HPPid = "hppid"
                };
                r.CustomerProfileObject = new CustomerProfile();
            }).Returns(true);


            User aProfile = new User()
            {
                EmailConsent = true
            };

            List <RoleMapping> roleMappings = new List <RoleMapping>();
            RoleMapping        role         = new RoleMapping();

            role.RoleId        = 1;
            role.RoleMappingId = 1;
            role.UserId        = 1;
            role.CreatedDate   = DateTime.UtcNow;
            roleMappings.Add(role);
            aProfile.RoleMappings = roleMappings;
            isacMock.Setup(x => x.FindOrInsertHPIDProfile(It.IsAny <ResponseBase>(), It.IsAny <RequestFindOrInsertHPIDProfile>(), out IsNewCustomer)).Returns(aProfile);



            GetProfileResponse response = custUtils.GetCustomerProfileByAuthentication(new UserAuthenticationInterchange(), It.IsAny <bool>(), "access", "url", It.IsAny <APIMethods>());

            Assert.IsTrue(response.ErrorList.Count == 0);
            Assert.IsTrue(response.CustomerProfileObject.EmailConsent.Equals(EmailConsentType.Y.ToString()));
        }