Exemplo n.º 1
0
        public async Task <OnboardingInfo> GetOnboardingInfo(string organizationId)
        {
            var response = await dynamicQueries.FindItemWhereAsync <JObject>(dbSettings.ResourcesCollectionId, Constants.Id, organizationId);

            if (response == null)
            {
                return(null);
            }
            return(JsonConvert.DeserializeObject <OnboardingInfo>(JsonConvert.SerializeObject(response.GetValue(Constants.EFormFormFields))));
        }
Exemplo n.º 2
0
        public void GetOnboardingInfoShouldValidate(string organizationId, JObject onboarding, dynamic expectedResult)
        {
            var dbResponse = dynamicQueries.FindItemWhereAsync <JObject>(dbSettings.ResourcesCollectionId, Constants.Id, organizationId);

            dbResponse.ReturnsForAnyArgs(onboarding);

            //act
            var response = onboardingInfo.GetOnboardingInfo(organizationId);

            expectedResult = JsonConvert.SerializeObject(expectedResult);
            var actualResult = JsonConvert.SerializeObject(response.Result);

            //assert
            Assert.Equal(expectedResult, actualResult);
        }
        public async Task <PersonalizedPlanViewModel> GeneratePersonalizedPlanAsync(CuratedExperience curatedExperience, Guid answersDocId)
        {
            var a2jPersonalizedPlan = await dynamicQueries.FindItemWhereAsync <JObject>(cosmosDbSettings.A2JAuthorDocsCollectionId, Constants.Id,
                                                                                        curatedExperience.A2jPersonalizedPlanId.ToString());

            var userAnswers = await backendDatabaseService.GetItemAsync <CuratedExperienceAnswers>(answersDocId.ToString(),
                                                                                                   cosmosDbSettings.GuidedAssistantAnswersCollectionId);

            if (a2jPersonalizedPlan == null || userAnswers == null || userAnswers.AnswersDocId == default(Guid))
            {
                return(null);
            }

            return(await personalizedPlanViewModelMapper.MapViewModel(personalizedPlanEngine.Build(a2jPersonalizedPlan, userAnswers)));
        }
        public void GeneratePersonalizedPlanAsyncValidate(CuratedExperience curatedExperience, CuratedExperienceAnswers expectedData, JObject personalizedPlan)
        {
            //arrange
            var a2jPersonalizedPlan = dynamicQueries.FindItemWhereAsync <JObject>(dbSettings.A2JAuthorDocsCollectionId, Constants.Id, curatedExperience.A2jPersonalizedPlanId.ToString());

            a2jPersonalizedPlan.ReturnsForAnyArgs <JObject>(personalizedPlan);

            var dbResponse = dbService.GetItemAsync <dynamic>(answersDocId.ToString(), dbSettings.GuidedAssistantAnswersCollectionId);
            var response   = personalizedPlanBusinessLogic.GeneratePersonalizedPlanAsync(curatedExperience, answersDocId);

            //act
            var actualResult   = JsonConvert.SerializeObject(response.Result);
            var expectedResult = JsonConvert.SerializeObject(expectedData);

            //assert
            Assert.Equal("null", actualResult);
        }