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

            GetProfileResponse response = custUtils.GetCustomerProfileByLogin(new UserAuthenticationInterchange(), It.IsAny <bool>(), It.IsAny <APIMethods>());

            Assert.IsTrue(response.ErrorList.Count == 1);
            Assert.IsTrue(response.ErrorList.Contains(Faults.InvalidCredentials));
        }
        public void GetCustomerProfileByLoginTest_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.GetCustomerProfileByLogin(new UserAuthenticationInterchange()
            {
                UserName = "******", Password = "******"
            }, It.IsAny <bool>(), It.IsAny <APIMethods>());

            Assert.IsTrue(response.ErrorList.Count == 1);
            Assert.IsTrue(response.ErrorList.Contains(Faults.HPIDInternalError));
        }
        public void GetCustomerProfileByLoginTest_Success()
        {
            bool IsNewCustomer             = false;
            CustomerHPIDUtils custUtils    = new CustomerHPIDUtils();
            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.GetCustomerProfileByLogin(new UserAuthenticationInterchange()
            {
                UserName = "******", Password = "******"
            }, It.IsAny <bool>(), It.IsAny <APIMethods>());

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