示例#1
0
        public void SetUp()
        {
            var logger = A.Fake <ILogger <LearningMenuController> >();

            config                          = A.Fake <IConfiguration>();
            configService                   = A.Fake <IConfigService>();
            courseContentService            = A.Fake <ICourseContentService>();
            tutorialContentDataService      = A.Fake <ITutorialContentDataService>();
            sessionService                  = A.Fake <ISessionService>();
            sectionContentDataService       = A.Fake <ISectionContentDataService>();
            diagnosticAssessmentDataService = A.Fake <IDiagnosticAssessmentDataService>();
            diagnosticAssessmentService     = A.Fake <IDiagnosticAssessmentService>();
            postLearningAssessmentService   = A.Fake <IPostLearningAssessmentService>();
            courseCompletionService         = A.Fake <ICourseCompletionService>();

            var user = new ClaimsPrincipal(new ClaimsIdentity(new[]
            {
                new Claim("learnCandidateID", CandidateId.ToString()),
                new Claim("UserCentreID", CentreId.ToString())
            }, "mock"));

            httpContextSession = new MockHttpContextSession();

            controller = new LearningMenuController(
                logger,
                config,
                configService,
                courseContentService,
                sectionContentDataService,
                tutorialContentDataService,
                diagnosticAssessmentDataService,
                diagnosticAssessmentService,
                postLearningAssessmentService,
                sessionService,
                courseCompletionService
                )
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = new DefaultHttpContext
                    {
                        User    = user,
                        Session = httpContextSession
                    }
                }
            };
        }
        public void SetUp()
        {
            var logger = A.Fake <ILogger <LearningMenuController> >();

            config                        = A.Fake <IConfiguration>();
            configDataService             = A.Fake <IConfigDataService>();
            courseContentService          = A.Fake <ICourseContentService>();
            tutorialContentDataService    = A.Fake <ITutorialContentDataService>();
            sessionService                = A.Fake <ISessionService>();
            sectionContentDataService     = A.Fake <ISectionContentDataService>();
            diagnosticAssessmentService   = A.Fake <IDiagnosticAssessmentService>();
            postLearningAssessmentService = A.Fake <IPostLearningAssessmentService>();
            courseCompletionService       = A.Fake <ICourseCompletionService>();
            clockService                  = A.Fake <IClockService>();

            controller = new LearningMenuController(
                logger,
                config,
                configDataService,
                courseContentService,
                sectionContentDataService,
                tutorialContentDataService,
                diagnosticAssessmentService,
                postLearningAssessmentService,
                sessionService,
                courseCompletionService,
                clockService
                ).WithDefaultContext()
                         .WithMockHttpContextSession()
                         .WithMockUser(true, CentreId, null, CandidateId, null)
                         .WithMockTempData()
                         .WithMockServices();

            authenticationService =
                (IAuthenticationService)controller.HttpContext.RequestServices.GetService(
                    typeof(IAuthenticationService)
                    );
            httpContextSession = controller.HttpContext.Session;
        }