public void LoginHPIDTest_ReturnsFault()
        {
            SettingRepository.SetSettingsRepositoryData(new List <AdmSettings>()
            {
                new AdmSettings {
                    ParamName = "HPIDEnabled", StringValue = "true"
                }
            });

            RESTAPIProfileController api = new RESTAPIProfileController();
            RESTAPILoginCredentials  req = new RESTAPILoginCredentials()
            {
                UserName = "",
                Password = "",
                CallerId = "",
                Platform = "",
                Locale   = ""
            };
            GetProfileResponse profileRes = new GetProfileResponse()
            {
                ErrorList = new HashSet <Fault>()
                {
                    new Fault("Profile", "", "")
                }
            };

            hpidMock.Setup(x => x.GetCustomerProfileByTestLogin(It.IsAny <UserAuthenticationInterchange>(), It.IsAny <bool>(), It.IsAny <APIMethods>())).Returns(profileRes);
            RESTAPILoginResponse response = api.Login(req);

            Assert.IsTrue(response.ErrorList.Count == 1);
            Assert.AreEqual(response.ErrorList.First().Origin, "Profile");
        }
        public void LoginTest_ReturnsFault()
        {
            RESTAPIProfileController api = new RESTAPIProfileController();
            RESTAPILoginCredentials  req = new RESTAPILoginCredentials()
            {
                UserName = "",
                Password = "",
                CallerId = "",
                Platform = "",
                Locale   = ""
            };
            GetProfileResponse profileRes = new GetProfileResponse()
            {
                ErrorList = new HashSet <Fault>()
                {
                    new Fault("Profile", "", "")
                }
            };

            //customerMock.Setup(x => x.GetCustomerProfile(It.IsAny<UserAuthenticationInterchange>(), It.IsAny<bool>())).Returns(profileRes);
            hpidMock.Setup(x => x.GetCustomerProfileByTestLogin(It.IsAny <UserAuthenticationInterchange>(), It.IsAny <bool>(), It.IsAny <APIMethods>())).Returns(profileRes);

            RESTAPILoginResponse response = api.Login(req);

            Assert.IsTrue(response.ErrorList.Count == 1);
            Assert.AreEqual(response.ErrorList.First().Origin, "Profile");
        }
        public void LoginTest_SessionTimeOutResponse()
        {
            DateTime loginDate = new DateTime(2019, 11, 28, 05, 06, 00);

            RESTAPIProfileController api = new RESTAPIProfileController();
            RESTAPILoginCredentials  req = new RESTAPILoginCredentials()
            {
                UserName = "",
                Password = "",
                CallerId = "",
                Platform = "",
                Locale   = "pl-PL"
            };
            GetProfileResponse profileRes = new GetProfileResponse()
            {
                Credentials = new AccessCredentials()
                {
                    UserID = 1000, SessionToken = "sessionToken", CallerId = "callerId"
                },
                CustomerProfileObject = new CustomerProfile()
                {
                    ActiveHealth = true
                },
                LoginDate = loginDate
            };

            hpidMock.Setup(x => x.GetCustomerProfileByTestLogin(It.IsAny <UserAuthenticationInterchange>(), It.IsAny <bool>(), It.IsAny <APIMethods>())).Returns(profileRes);

            //customerMock.Setup(x => x.GetCustomerProfile(It.IsAny<UserAuthenticationInterchange>(), It.IsAny<bool>())).Returns(profileRes);

            RESTAPILoginResponse response = api.Login(req);

            Assert.IsNotNull(response.TimeOut);
            Assert.AreEqual("2019-11-28T06:06:00Z", response.TimeOut);
        }
        public void LoginTest_ReturnsValidCredentials_CallRegisterMobile()
        {
            RESTAPIProfileController api = new RESTAPIProfileController();
            RESTAPILoginCredentials  req = new RESTAPILoginCredentials()
            {
                UserName    = "",
                Password    = "",
                CallerId    = "callerId",
                Platform    = "PLATFORM",
                DeviceToken = "deviceToken"
            };
            GetProfileResponse profileRes = new GetProfileResponse()
            {
                Credentials = new AccessCredentials()
                {
                    UserID = 1000, SessionToken = "sessionToken"
                },
                CustomerProfileObject = new CustomerProfile()
                {
                    ActiveHealth = true
                }
            };

            hpidMock.Setup(x => x.GetCustomerProfileByTestLogin(It.IsAny <UserAuthenticationInterchange>(), It.IsAny <bool>(), It.IsAny <APIMethods>())).Returns(profileRes);

            //customerMock.Setup(x => x.GetCustomerProfile(It.IsAny<UserAuthenticationInterchange>(), It.IsAny<bool>())).Returns(profileRes);

            RESTAPILoginResponse response = api.Login(req);

            Assert.IsTrue(response.ErrorList.Count == 0);
        }
        public void LoginTest_ReturnSsessionToken()
        {
            RESTAPIProfileController api = new RESTAPIProfileController();
            RESTAPILoginCredentials  req = new RESTAPILoginCredentials()
            {
                UserName = "",
                Password = "",
                CallerId = "",
                Platform = "",
                Locale   = "en-US"
            };
            GetProfileResponse profileRes = new GetProfileResponse()
            {
                Credentials = new AccessCredentials()
                {
                    UserID = 1000, SessionToken = "sessionToken", CallerId = "callerId"
                },
                CustomerProfileObject = new CustomerProfile()
                {
                    ActiveHealth = true
                }
            };

            hpidMock.Setup(x => x.GetCustomerProfileByTestLogin(It.IsAny <UserAuthenticationInterchange>(), It.IsAny <bool>(), It.IsAny <APIMethods>())).Returns(profileRes);

            //customerMock.Setup(x => x.GetCustomerProfile(It.IsAny<UserAuthenticationInterchange>(), It.IsAny<bool>())).Returns(profileRes);
            RESTAPILoginResponse response = api.Login(req);

            Assert.IsTrue(response.SessionToken.Equals("sessionToken"));
        }
        public void LoginTest_ReturnsValidCredentials_MobileFault()
        {
            RESTAPIProfileController api = new RESTAPIProfileController();
            RESTAPILoginCredentials  req = new RESTAPILoginCredentials()
            {
                UserName = "",
                Password = "",
                CallerId = "",
                Platform = ""
            };
            GetProfileResponse profileRes = new GetProfileResponse()
            {
                Credentials = new AccessCredentials()
                {
                    UserID = 1000, SessionToken = "sessionToken", CallerId = "CallerId"
                },
                CustomerProfileObject = new CustomerProfile()
                {
                    ActiveHealth = true
                }
            };

            hpidMock.Setup(x => x.GetCustomerProfileByTestLogin(It.IsAny <UserAuthenticationInterchange>(), It.IsAny <bool>(), It.IsAny <APIMethods>())).Returns(profileRes);

            // customerMock.Setup(x => x.GetCustomerProfile(It.IsAny<UserAuthenticationInterchange>(), It.IsAny<bool>())).Returns(profileRes);
            ResponseBase mobileResponse = new ResponseBase()
            {
                ErrorList = new HashSet <Fault>()
                {
                    new Fault("", "", "")
                }
            };
            RESTAPILoginResponse response = api.Login(req);

            Assert.IsTrue(response.ErrorList.Count == 0);
            Assert.IsTrue(response.UserID == 1000);
            Assert.AreEqual(response.SessionToken, "sessionToken");
            Assert.AreEqual(response.CallerId, "CallerId");
        }