Beispiel #1
0
        public When_Recording_Referrals_And_Check_Answers_Is_Submitted_Successfully()
        {
            var httpContextAccessor = Substitute.For <IHttpContextAccessor>();

            var config = new MapperConfiguration(c =>
            {
                c.AddMaps(typeof(CheckAnswersDtoMapper).Assembly);
                c.ConstructServicesUsing(type =>
                                         type.Name.Contains("LoggedInUserEmailResolver") ?
                                         new LoggedInUserEmailResolver <CheckAnswersViewModel, CheckAnswersDto>(httpContextAccessor) :
                                         type.Name.Contains("LoggedInUserNameResolver") ?
                                         (object)new LoggedInUserNameResolver <CheckAnswersViewModel, CheckAnswersDto>(httpContextAccessor) :
                                         type.Name.Contains("UtcNowResolver") ?
                                         new UtcNowResolver <CheckAnswersViewModel, CheckAnswersDto>(new DateTimeProvider()) :
                                         null);
            });

            var mapper = new Mapper(config);

            _opportunityService = Substitute.For <IOpportunityService>();

            var opportunityController = new OpportunityController(_opportunityService, mapper);
            var controllerWithClaims  = new ClaimsBuilder <OpportunityController>(opportunityController)
                                        .AddUserName(ModifiedBy)
                                        .Build();

            httpContextAccessor.HttpContext.Returns(controllerWithClaims.HttpContext);

            _result = controllerWithClaims.SaveCheckAnswers(OpportunityId, OpportunityItemId).GetAwaiter().GetResult();
        }