Ejemplo n.º 1
0
        public void _12kIncomeTest()
        {
            var customerName = "Customer with 12k income";
            var customer     = new Customer {
                AccountType = _accountTypeRepository.GetAccountTypeById(1), CustomerName = customerName
            };

            _customerRepository.Add(customer);
            var survey   = _surveyRepository.GetAll().FirstOrDefault(s => s.Title == Survey.FirstSurvey.Item2);
            var custSurv = new CustomerSurvey
            {
                CustomerId = customer.Id,
                SurveyId   = survey.Id,
                Date       = DateTime.Now
            };

            _customerSurveyRepository.Add(custSurv);
            var ageQuestion = _questionRepository.GetAll().FirstOrDefault(q => q.QuestionText == Question.Age.Value);               //Age?
            var selectedAge = _possibleAnswersRepository.GetAll().FirstOrDefault(pa => pa.Text == PossibleAnswers.Age_18_64.Value); //"18-64"
            var answerAge   = new Answer {
                CustomerId = customer.Id, SurveyId = survey.Id, QuestionId = ageQuestion.Id, SelectedAnswerId = selectedAge.Id
            };

            _answerRepository.Add(answerAge);
            var studQuestion = _questionRepository.GetAll().FirstOrDefault(q => q.QuestionText == Question.Student.Value);;   //Is Student?
            var selectedStud = _possibleAnswersRepository.GetAll().FirstOrDefault(pa => pa.Text == PossibleAnswers.No.Value); //"no"
            var answerStud   = new Answer {
                CustomerId = customer.Id, SurveyId = survey.Id, QuestionId = studQuestion.Id, SelectedAnswerId = selectedStud.Id
            };

            _answerRepository.Add(answerStud);
            var incomeQuestion = _questionRepository.GetAll().FirstOrDefault(q => q.QuestionText == Question.Income.Value);                 //Income?
            var selectedIncome = _possibleAnswersRepository.GetAll().FirstOrDefault(pa => pa.Text == PossibleAnswers.Income_1_12000.Value); //"1-12000"
            var answerIncome   = new Answer {
                CustomerId = customer.Id, SurveyId = survey.Id, QuestionId = incomeQuestion.Id, SelectedAnswerId = selectedIncome.Id
            };

            _answerRepository.Add(answerIncome);

            var    bundleRecomemndation = new BundleRecomendationService(_context);
            Bundle recomendeBundle      = bundleRecomemndation.Recommend(customer, survey);

            _output.WriteLine($"Recomended Bundle: {recomendeBundle?.BundleName} Value: {recomendeBundle?.Value}");
            Assert.Equal("Classic", recomendeBundle?.BundleName);
            foreach (var productBundle in recomendeBundle?.ProductIncluded)
            {
                _output.WriteLine($"\tIncluded Product: {productBundle.Product.ProductName}");
            }
        }