Exemplo n.º 1
0
        public void UpdateExistingConsumerProfile()
        {
            var createResponse = CreateProfile();

            #region Get profile

            var getProfileResponse = GetProfileConsumer(createResponse.Payload.ConsumerProfileIDs.First().ConsumerProfileID, createResponse.Payload.ConsumerProfileIDs.First().ConsumerProfileIDType);

            Assert.IsFalse(getProfileResponse.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{getProfileResponse.Errors?.Log()}");
            Assert.IsNotNull(getProfileResponse.Payload, "Payload is null");
            Assert.IsNotNull(getProfileResponse.Payload.CurrentValues, "There are no values related with profile");
            Assert.IsTrue(getProfileResponse.Payload.CurrentValues.Count != 0,
                          "There are no values related with profile");
            #endregion

            #region Update profile

            var cityToChange  = _consumerOperations.GetCityAddressOfConsumer(getProfileResponse);
            var updateRequest = new INTEGRATION.CreateOrUpdateProfileConsumerRequest()
            {
                AgentState = _agentState,
            };
            updateRequest.PopulateAgentData(updateRequest.AgentState);
            var updateData = new CreateOrUpdateProfileConsumerData(updateRequest);
            var values     = getProfileResponse.Payload.CurrentValues.Where(x =>
                                                                            x.InfoKey != InfoKeyNames.issue_Date && x.InfoKey != InfoKeyNames.last_Modified_Date &&
                                                                            x.InfoKey != InfoKeyNames.issue_Date.Replace("_", "") &&
                                                                            x.InfoKey != InfoKeyNames.last_Modified_Date.Replace("_", "")
                                                                            ).ToList();
            var newCity          = _consumerOperations.SetRandomAddressCityOfConsumer(values);
            var generatorCounter = 0;
            while (newCity.Equals(cityToChange) && generatorCounter < 5)
            {
                newCity = _consumerOperations.SetRandomAddressCityOfConsumer(values);
                generatorCounter++;
            }

            Assert.AreNotEqual(cityToChange, newCity, "Could not generate random city value");

            var createdProfile = createResponse.Payload.ConsumerProfileIDs.First();
            var updateResponse = _consumerOperations.UpdateProfileConsumerData(updateData, values,
                                                                               createdProfile.ConsumerProfileID, createdProfile.ConsumerProfileIDType);
            Assert.IsFalse(updateResponse.Errors.Any(),
                           $" {Environment.NewLine}Errors: {Environment.NewLine}{updateResponse.Errors?.Log()}");
            Assert.IsNotNull(updateResponse.Payload.ConsumerProfileIDs);
            Assert.AreEqual(updateResponse.Payload.ConsumerProfileIDs.First().ConsumerProfileID,
                            createResponse.Payload.ConsumerProfileIDs.First().ConsumerProfileID);

            var updatedProfile = GetProfileConsumer(createResponse.Payload.ConsumerProfileIDs.First().ConsumerProfileID,
                                                    createResponse.Payload.ConsumerProfileIDs.First().ConsumerProfileIDType);

            var updatedCity = _consumerOperations.GetCityAddressOfConsumer(updatedProfile);
            Assert.AreEqual(newCity, updatedCity);
            #endregion
        }
        private CreateOrUpdateProfileConsumerResponse CreateProfile()
        {
            var createRequest = new INTEGRATION.CreateOrUpdateProfileConsumerRequest()
            {
                AgentState = _agentState
            };

            createRequest.PopulateAgentData(createRequest.AgentState);
            var createData = new CreateOrUpdateProfileConsumerData(createRequest);

            return(_consumerOperations.CreateProfileConsumer(createData));
        }
Exemplo n.º 3
0
        public void CreateOrUpdateProfileConsumer_ValidateShouldReturnFieldsToCollect()
        {
            var request = new INTEGRATION.CreateOrUpdateProfileConsumerRequest()
            {
                AgentState = _agentState
            };

            request.PopulateAgentData(request.AgentState);
            var data     = new CreateOrUpdateProfileConsumerData(request);
            var response = _consumerOperations.CreateOrUpdateProfileConsumerBaseData(data);

            Assert.IsFalse(response.Errors.Any(), $" {Environment.NewLine}Errors: {Environment.NewLine}{response.Errors?.Log()}");
            var containsFirstIdCategory = ContainsCategory(response.Payload.FieldsToCollect,
                                                           InfoKeyCategories.profileSaveOrUpdateInfoSet);
            var containsSecondIdCategory = ContainsCategory(response.Payload.FieldsToCollect,
                                                            InfoKeyCategories.consumerNotificationPlusUpdateinfoSet);

            Assert.IsTrue(containsFirstIdCategory && containsSecondIdCategory,
                          "Ensure that profile editor limits for create or update profile consumer are configured properly in the current environment");
        }
        public void SearchExistingConsumerProfiles()
        {
            var createRequest = new INTEGRATION.CreateOrUpdateProfileConsumerRequest()
            {
                AgentState = _agentState
            };

            createRequest.PopulateAgentData(createRequest.AgentState);
            var createData     = new CreateOrUpdateProfileConsumerData(createRequest);
            var createResponse = _consumerOperations.CreateProfileConsumer(createData);

            Assert.IsFalse(createResponse.Errors.Any(),
                           $" {Environment.NewLine}Errors: {Environment.NewLine}{createResponse.Errors?.Log()}");

            var searchRequest = new INTEGRATION.SearchConsumerProfileRequest()
            {
                AgentState = _agentState
            };

            var exceptionList = new List <string>();

            foreach (var searchCriteria in _searchCriteriaList)
            {
                searchRequest.PopulateAgentData(searchRequest.AgentState);
                var searchData     = new SearchConsumerProfilesData(searchRequest);
                var currentProfile = GetProfileConsumer(
                    createResponse.Payload.ConsumerProfileIDs.First().ConsumerProfileID,
                    createResponse.Payload.ConsumerProfileIDs.First().ConsumerProfileIDType);
                try
                {
                    var searchResponse =
                        _consumerOperations.SearchConsumerProfiles(searchData, searchCriteria, null);
                    Assert.IsFalse(searchResponse.Errors.Any(),
                                   $" {Environment.NewLine}Errors: {Environment.NewLine}{searchResponse.Errors?.Log()}");
                    Assert.IsTrue(searchResponse.Payload.FieldsToCollect != null &&
                                  searchResponse.Payload.FieldsToCollect.Count != 0);
                    Assert.IsTrue(searchResponse.Payload.ConsumerProfileSearchInfos?.Count == 0,
                                  $"There are not search results for criteria {searchCriteria.ToString()}");

                    var valuesToBeSearched =
                        _consumerOperations.GetCorectSearchValues(searchResponse.Payload.FieldsToCollect,
                                                                  currentProfile.Payload.CurrentValues);
                    var searchResponseWithResult =
                        _consumerOperations.SearchConsumerProfiles(searchData, searchCriteria, valuesToBeSearched);
                    Assert.IsFalse(searchResponseWithResult.Errors.Any(),
                                   $" {Environment.NewLine}Errors: {Environment.NewLine}{searchResponseWithResult.Errors?.Log()}");
                    Assert.IsTrue(searchResponseWithResult.Payload.FieldsToCollect != null &&
                                  searchResponseWithResult.Payload.FieldsToCollect.Count == 0, "There are fields to collect");
                    Assert.IsTrue(
                        searchResponseWithResult.Payload.ConsumerProfileSearchInfos != null &&
                        searchResponseWithResult.Payload.ConsumerProfileSearchInfos.Count != 0,
                        $"There are not search results for criteria {searchCriteria.ToString()}");
                    Assert.IsTrue(searchResponseWithResult.Payload.ConsumerProfileSearchInfos.FirstOrDefault(x =>
                                                                                                             x.ConsumerProfileID == createResponse.Payload.ConsumerProfileIDs.First()
                                                                                                             .ConsumerProfileID) != null, "Couldn't find profile in search results");
                }
                catch (Exception ex)
                {
                    exceptionList.Add(
                        $"Failed search for criteria {searchCriteria.ToString()}. Exception: {ex.Message}");
                }
            }

            Assert.IsTrue(exceptionList.Count == 0, string.Join("; ", exceptionList.ToArray()));
        }