public async Task IfAnswerIsValidMovesToNextQuestion()
        {
            var answerRequest = new QuestionPostRequestViewModel()
            {
                QuestionNumber = 3, AssessmentType = "short", Answer = "answer1"
            };
            var currentQuestion = new GetQuestionResponse()
            {
                MaxQuestionsCount = 10, CurrentQuestionNumber = 3, NextQuestionNumber = 4
            };
            var answerResponse = new PostAnswerResponse()
            {
                IsSuccess = true, NextQuestionNumber = 4
            };

            A.CallTo(() => Session.HasValidSession()).Returns(true);
            A.CallTo(() => ApiService.GetQuestion(answerRequest.AssessmentType, answerRequest.QuestionNumber)).Returns(currentQuestion);
            A.CallTo(() => ApiService.AnswerQuestion(answerRequest.AssessmentType, answerRequest.QuestionNumber, answerRequest.QuestionNumber, answerRequest.Answer)).Returns(answerResponse);

            var actionResponse = await AssessmentController.Index(answerRequest).ConfigureAwait(false);

            Assert.IsType <RedirectResult>(actionResponse);
            var redirectResult = actionResponse as RedirectResult;

            Assert.Equal($"~/{RouteName.Prefix}/assessment/short/4", redirectResult.Url);
        }
Exemplo n.º 2
0
    public static void GetAssessment(Model_Assessment parameters)
    {
        List <Model_Assessment> ret = AssessmentController.GetAssessmentList(parameters);


        AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON());
    }
        public async Task NullViewModelReturnsBadRequest()
        {
            QuestionGetRequestViewModel viewModel = null;
            var actionResponse = await AssessmentController.Index(viewModel).ConfigureAwait(false);

            Assert.IsType <BadRequestResult>(actionResponse);
        }
Exemplo n.º 4
0
    public static void GetQtAll(Model_QType parameters)
    {
        IList <Model_QType> ret = AssessmentController.GetQTypeAll();


        AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON());
    }
        public void CreateAssessment_Post_Valid()
        {
            //Arrange
            var controller = new AssessmentController(_ITrainingService, _IAssessmentService);

            //Initialize model
            AssessmentPaperViewModel assessmentPaperViewModel = new AssessmentPaperViewModel();

            assessmentPaperViewModel.AssessmentPaperId = 0;
            assessmentPaperViewModel.CourseId          = 27;
            assessmentPaperViewModel.AssessmentDate    = DateTime.Now;
            assessmentPaperViewModel.TimeDuration      = 120;
            assessmentPaperViewModel.CreatedOn         = DateTime.Now;
            assessmentPaperViewModel.LastEditedOn      = DateTime.Now;
            assessmentPaperViewModel.IsActive          = true;

            //Act
            var result = (ActionResult)controller.CreateAssessment(assessmentPaperViewModel);

            //Assert
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            RedirectToRouteResult routeResult = result as RedirectToRouteResult;

            Assert.AreEqual(routeResult.RouteValues["action"], "ShowAssessmentPaperDetails");
        }
        public async Task QuestionsMustBeAnsweredInOrder()
        {
            var viewModel = new QuestionGetRequestViewModel()
            {
                QuestionNumber = 2, AssessmentType = "name1"
            };
            var expectedQuestion = new GetQuestionResponse()
            {
                MaxQuestionsCount = 3, QuestionNumber = 1
            };
            var expectedAssessment = new GetAssessmentResponse()
            {
                CurrentQuestionNumber = 1
            };

            A.CallTo(() => Session.HasValidSession()).Returns(true);
            A.CallTo(() => ApiService.GetQuestion(viewModel.AssessmentType, viewModel.QuestionNumber)).Returns(expectedQuestion);
            A.CallTo(() => ApiService.GetAssessment()).Returns(expectedAssessment);

            var actionResponse = await AssessmentController.Index(viewModel).ConfigureAwait(false);

            Assert.IsType <RedirectResult>(actionResponse);

            var redirectResult = actionResponse as RedirectResult;

            Assert.Equal($"~/{RouteName.Prefix}/assessment/name1/1", redirectResult.Url);
        }
Exemplo n.º 7
0
        public void CanSubmitAssessment()
        {
            // Arrange
            var patientKey = Guid.NewGuid();
            var key        = Guid.NewGuid();
            var asyncRequestDispatcherMock = new Mock <IAsyncRequestDispatcher>();

            asyncRequestDispatcherMock.Setup(rd => rd.GetAsync <SubmitAssessmentResponse>())
            .Returns(
                Task.FromResult(new SubmitAssessmentResponse
            {
                ScoreDto = new ScoreDto()
                {
                    Value = 1
                }
            }));

            asyncRequestDispatcherMock.Setup(rd => rd.Get <GetPatientDtoResponse>()).Returns(new GetPatientDtoResponse
            {
                DataTransferObject =
                    new PatientDto {
                    Key = patientKey, Gender = new LookupDto()
                    {
                        Code = "Male", Name = "Male"
                    }
                }
            });
            var requestDisplatcherFactoryMock = new Mock <IRequestDispatcherFactory>();

            requestDisplatcherFactoryMock.Setup(r => r.CreateRequestDispatcher())
            .Returns(asyncRequestDispatcherMock.Object);

            var controller = new AssessmentController(requestDisplatcherFactoryMock.Object,
                                                      new Mock <IResourcesManager>().Object,
                                                      new Mock <IDbConnectionFactory>().Object);

            ActionResult actionResult = null;
            var          wait         = new ManualResetEvent(false);


            // Act
            var task = controller.Submit(key, patientKey, "Name");

            task.ContinueWith(result =>
            {
                actionResult = result.Result;
                wait.Set();
            });
            wait.WaitOne();


            // Assert
            var partialViewResult = actionResult as PartialViewResult;

            Assert.AreEqual("ScoreHeader", partialViewResult.ViewName);
            var scoreDto = (partialViewResult.Model as ScoreHeaderViewModel).Score;

            Assert.AreEqual(1, scoreDto.Value);
            Assert.AreEqual("Male", (partialViewResult.ViewData["Patient"] as PatientDto).Gender.Code);
        }
Exemplo n.º 8
0
    public static void GetSectionAll(Model_AsSection parameters)
    {
        IList <Model_AsSection> ret = AssessmentController.GetSectionList();


        AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON());
    }
Exemplo n.º 9
0
    protected void Button10_Click(object sender, EventArgs e)
    {
        string      strtitle = txtQtitle.Text.Trim();
        bool        Status   = bool.Parse(qstatus.SelectedValue);
        Model_QType q        = new Model_QType
        {
            Title  = strtitle,
            Status = Status
        };


        Button btn = (Button)sender;

        if (!string.IsNullOrEmpty(Request.QueryString["qt"]))
        {
            int bytID = int.Parse(Request.QueryString["qt"]);
            q.QTID = bytID;

            if (AssessmentController.EditQType(q))
            {
                Response.Redirect("Assessmentoptionaddedit?tab=3");
            }
        }
        else
        {
            if (AssessmentController.AddQtype(q) > 0)
            {
                Response.Redirect(Request.Url.ToString());
            }
        }
    }
Exemplo n.º 10
0
        public void SectoionControllerRedirectedToCorrectPage()
        {
            var requestDispatcherFactoryMock = new Mock <IRequestDispatcherFactory>();
            var routeNavigationServiceMock   = new Mock <IRouteNavigationService>();

            routeNavigationServiceMock.Setup(i => i.GetInitialRoute(It.IsAny <long?> ()))
            .Returns(new RouteInfo("GeneralInformationSection", 0));
            var patientAccessControlManagerMock = new Mock <IPatientAccessControlManager>();

            var assessmentController = new AssessmentController(requestDispatcherFactoryMock.Object,
                                                                routeNavigationServiceMock.Object,
                                                                patientAccessControlManagerMock.Object);

            var result = assessmentController.Edit(It.IsAny <long>());

            Assert.IsNotNull(result);
            var redirectToRouteResult = result as RedirectToRouteResult;

            Assert.AreEqual(redirectToRouteResult.RouteName, "SectionRoute");

            var routes = new RouteCollection();

            RouteConfig.RegisterRoutes(routes);
            RouteTestHelper.AssertRoute(routes, redirectToRouteResult.RouteValues, new { id = "0", section = "GeneralInformationSection" });
        }
        public void NullViewModelReturnsBadRequest()
        {
            AssessmentSaveRequestViewModel viewModel = null;
            var actionResponse = AssessmentController.Save(viewModel);

            Assert.IsType <BadRequestResult>(actionResponse);
        }
Exemplo n.º 12
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string s  = SectionTitle.Text.Trim();
        string c  = txtCode.Text.Trim();
        string i  = txtintro.Text.Trim();
        bool   st = bool.Parse(status.SelectedValue);
        int    pr = int.Parse(txtpri.Text);


        Button btn = (Button)sender;

        if (!string.IsNullOrEmpty(Request.QueryString["section"]))
        {
            byte bytID = byte.Parse(Request.QueryString["section"]);
            if (AssessmentController.EditSection(bytID, s, c, i, st, pr))
            {
                Response.Redirect("Assessmentoptionaddedit");
            }
        }
        else
        {
            if (AssessmentController.AddSection(s, c, i, pr) > 0)
            {
                Response.Redirect(Request.Url.ToString());
            }
        }
    }
Exemplo n.º 13
0
        public async Task NullViewModelReturnsBadRequest()
        {
            AssessmentReferencePostRequest viewModel = null;
            var actionResponse = await AssessmentController.Reference(viewModel).ConfigureAwait(false);

            Assert.IsType <BadRequestResult>(actionResponse);
        }
Exemplo n.º 14
0
    public static void GetSubSectionAll2(Model_AsSubSection2 parameters)
    {
        IList <Model_AsSubSection2> ret = AssessmentController.getSubsectionBySecId2(parameters);


        AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON());
    }
Exemplo n.º 15
0
    protected void dropSection_SelectedIndexChanged(object sender, EventArgs e)
    {
        int intSCID           = int.Parse(dropSection.SelectedValue);
        Model_AsSubSection ss = new Model_AsSubSection
        {
            SCID = intSCID,
        };

        List <Model_AsSubSection> sub = AssessmentController.getSubsectionBySecId(ss);

        dropsub.DataSource     = sub;
        dropsub.DataTextField  = "Title";
        dropsub.DataValueField = "SUCID";
        dropsub.DataBind();

        //if(intSCID == 7)
        //{
        //    dropsubrigth.DataSource = sub;
        //    dropsubrigth.DataTextField = "Title";
        //    dropsubrigth.DataValueField = "SUCID";
        //    dropsubrigth.DataBind();

        //    dropsubrigth.Visible = true;


        //}
        //else
        //{
        //    dropsubrigth.Visible = false;
        //}


        //Model_AsSection secs = AssessmentController.getSectionByID(intSCID);
        //txtCode.Text = secs.Code.ToString();
    }
Exemplo n.º 16
0
        public async Task TestGetPatientFound()
        {
            // Arrange
            var mockExternalService = new Mock <IExternalDemographicsAPIService>();

            mockExternalService
            .Setup(x => x.GetPatientAsync(1))
            .ReturnsAsync(new PatientModel());

            var mockAssessmentService = new Mock <IAssessmentService>();

            mockAssessmentService
            .Setup(x => x.GenerateAssessment(It.IsAny <PatientModel>()))
            .ReturnsAsync(new AssessmentResult(1, RiskLevel.None));

            var controller = new AssessmentController(mockExternalService.Object, mockAssessmentService.Object);

            // Act
            var result = await controller.Get(1);

            // Assert
            var actionResult = Assert.IsAssignableFrom <OkObjectResult>(result);
            var modelResult  = Assert.IsAssignableFrom <AssessmentResult>(actionResult.Value);

            Assert.Equal(RiskLevel.None, modelResult.RiskLevel);
        }
        public async Task ReferenceReturnsView()
        {
            A.CallTo(() => Session.HasValidSession()).Returns(true);

            var actionResponse = await AssessmentController.Reference().ConfigureAwait(false);

            Assert.IsType <ViewResult>(actionResponse);
        }
Exemplo n.º 18
0
        public void Setup()
        {
            _queryDispatcher            = A.Fake <IQueryDispatcher>();
            _assessmentViewModelBuilder = A.Fake <IAssessmentViewModelBuilder>();
            _commandDispatcher          = A.Fake <ICommandDispatcher>();
            _dateTimeProvider           = A.Fake <IDateTimeProvider>();

            _controller = new AssessmentController(_queryDispatcher, _assessmentViewModelBuilder, _commandDispatcher, _dateTimeProvider);
        }
Exemplo n.º 19
0
 public void Setup()
 {
     controller = new AssessmentController(_nullOrEmptyManager.Object, _positiveDivisorManager.Object, _commonNumberManager.Object, _triangleManager.Object)
     {
         Request = new HttpRequestMessage()
         {
             Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } }
         }
     };
 }
Exemplo n.º 20
0
        public AssessmentTestBase()
        {
            mapper            = A.Fake <IMapper>();
            sessionService    = A.Fake <ISessionService>();
            assessmentService = A.Fake <IAssessmentService>();
            logService        = A.Fake <ILogService>();
            notifyOptions     = A.Fake <NotifyOptions>();

            assessmentController = new AssessmentController(logService, mapper, assessmentService, sessionService, notifyOptions);
        }
        public void CreateAssessment_Get()
        {
            // Arrange
            var controller = new AssessmentController(_ITrainingService, _IAssessmentService);

            // Act
            var result = (ViewResult)controller.CreateAssessment();

            // Assert
            Assert.AreEqual("CreateAssessment", result.ViewName);
        }
Exemplo n.º 22
0
        public async Task WhenReturningToAssessmentReturnsBadRequestIfAssessmentResponseIsNull()
        {
            GetAssessmentResponse assessmentResponse = null;

            A.CallTo(() => ApiService.GetAssessment()).Returns(assessmentResponse);
            A.CallTo(() => Session.HasValidSession()).Returns(true);

            var actionResponse = await AssessmentController.Return().ConfigureAwait(false);

            Assert.IsType <BadRequestResult>(actionResponse);
        }
Exemplo n.º 23
0
        public async Task WhenSessionIdDoesNotExistRedirectsToRoot()
        {
            A.CallTo(() => Session.HasValidSession()).Returns(false);

            var actionResponse = await AssessmentController.Return().ConfigureAwait(false);

            Assert.IsType <RedirectResult>(actionResponse);
            var redirectResult = actionResponse as RedirectResult;

            Assert.Equal($"~/{RouteName.Prefix}/", redirectResult.Url);
        }
Exemplo n.º 24
0
 public void GivenTheUserHasEnteredAllTheInformation()
 {
     _assessmentModel = new AssessmentViewModel
     {
         AssessmentId              = new Guid(),
         PatientFirstName          = "FirstName",
         Stage1DecisionToBeMade    = "Test decision about mca",
         Stage1DecisionClearlyMade = true
     };
     _controller = new AssessmentController(_assessmentBuilder, _workflowHandler, _pdfCreationProvider, _assessmentHelper, _terminatedViewModelBuilder, _patientHelper, _roleHelper, _feedBackBuilder, _copyrightViewModelBuilder);
 }
Exemplo n.º 25
0
        public async Task WhenSessionExistsAndModelStateIsNotValidReturnsView()
        {
            var assessmentEmailPostRequest = new AssessmentEmailPostRequest();

            A.CallTo(() => Session.HasValidSession()).Returns(true);
            AssessmentController.ModelState.AddModelError("Key1", "Some Error");

            var actionResponse = await AssessmentController.Email(assessmentEmailPostRequest).ConfigureAwait(false);

            Assert.IsType <ViewResult>(actionResponse);
        }
        public void ShowAssessmentPaperDetails()
        {
            // Arrange
            var controller = new AssessmentController(_ITrainingService, _IAssessmentService);

            // Act
            int assessmentPaperId = 1;
            var result            = (ViewResult)controller.ShowAssessmentPaperDetails(assessmentPaperId);

            // Assert
            Assert.AreEqual("ShowAssessmentPaperDetails", result.ViewName);
        }
        public async Task IfNoAnswerIsProvidedReturnsView()
        {
            var viewModel = new QuestionPostRequestViewModel()
            {
                QuestionNumber = 3, AssessmentType = "short"
            };

            A.CallTo(() => Session.HasValidSession()).Returns(true);

            var actionResponse = await AssessmentController.Index(viewModel).ConfigureAwait(false);

            Assert.IsType <ViewResult>(actionResponse);
        }
        public async Task WhenSessionIdIsReloadedRedirectToAssessmentReturn()
        {
            var sessionId = "sessionId1";

            A.CallTo(() => ApiService.ReloadUsingSessionId(sessionId)).Returns(true);

            var actionResponse = await AssessmentController.Reload(sessionId).ConfigureAwait(false);

            Assert.IsType <RedirectResult>(actionResponse);
            var redirectResult = actionResponse as RedirectResult;

            Assert.Equal($"~/{RouteName.Prefix}/assessment/return", redirectResult.Url);
        }
        public void AddNewQuestion()
        {
            // Arrange
            var controller = new AssessmentController(_ITrainingService, _IAssessmentService);

            // Act
            int assessmentPaperId = 1;
            var result            = (ActionResult)controller.AddNewQuestion(assessmentPaperId);

            // Assert
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.AreEqual("AddNewQuestion", ((ViewResult)result).ViewName);
        }
Exemplo n.º 30
0
        public async Task WhenModelStateIsInvalidRedirectsView()
        {
            AssessmentController.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext(),
            };
            AssessmentController.ModelState.AddModelError("key1", "Error1");

            var viewModel      = new AssessmentReferencePostRequest();
            var actionResponse = await AssessmentController.Reference(viewModel).ConfigureAwait(false);

            Assert.IsType <ViewResult>(actionResponse);
        }
Exemplo n.º 31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssessmentResultsPanel"/> class.
        /// </summary>
        /// <param name="showToolbar">if set to <c>true</c> [show toolbar].</param>
        public AssessmentResultsPanel(bool showToolbar) {
            InitializeComponent();

            GMEManager cm = GMEManager.Instance;
            this.assessmentController = (AssessmentController)cm.Get("AssessmentEditor");

            if (showToolbar)
                this.toolStripContainer.TopToolStripPanel.Controls.Add(this.toolStrip);
            
            this.graphDataButton.Enabled = false;
            this.backButton.Enabled = false;
            this.forwardButton.Enabled = false;

            logger.Debug("AssessmentResultPanel created");
        }
Exemplo n.º 32
0
        public AssessmentToolbar() {

            InitializeComponent();
            
            this.clearAll();
            GMEManager cm = GMEManager.Instance;

            RootController projectController = (RootController)cm.Get("ProjectEditor");
            this.assessmentController = (AssessmentController)cm.Get("AssessmentEditor");
            this.assessmentController.ComponentUpdate += 
                new ComponentUpdateHandler(this.cEvent_ComponentUpdate);

            // Init Simulation Selection CustomCombo
            this.simmulationComboBox.Controller = projectController;
            this.simmulationComboBox.Type = assessmentController.RootComponentType;
            this.simmulationComboBox.LinkType = projectController.RootComponentType;
            this.simmulationComboBox.SelectionChangeCommitted +=
                new EventHandler(this.simmulationComboBox_SelectionChangeCommitted);

            logger.Debug("Created AssessmentToolbar");
        }
Exemplo n.º 33
0
        public static void Main() {
            IModel myModel = new Model.Model("localhost", 3306, "root", "devpass", "most");
            myModel.ConfigurationPath = @"C:\dev\BACKUP A-Model\Projects\IO-AOC\Config";
            AssessmentController ass = new AssessmentController(myModel, "ProjectEditor");
            IXPathNavigable runs = ass.GetSimRunData(1059);

            Application.Run(new AssessmentGraphSetupForm(runs));
        }