/// <summary>
 /// Initializes a new instance of the <see cref="ReferenceDataControllerTest"/> class.
 /// </summary>
 public ReferenceDataControllerTest()
 {
     this.manager = new Mock<IReferenceDataManager>();
     this.controller = new ReferenceDataController(this.manager.Object);
     this.controller.Request = new HttpRequestMessage();
     this.controller.Configuration = new HttpConfiguration();
 }
 public void Setup()
 {
     _mocker = AutoMock.GetLoose();
     _bookingsApiClientMock = _mocker.Mock <IBookingsApiClient>();
     _userIdentityMock      = _mocker.Mock <IUserIdentity>();
     _controller            = _mocker.Create <ReferenceDataController>();
 }
Beispiel #3
0
        public async Task And_Exception_Then_Returns_Bad_Request(
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] ReferenceDataController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetCandidateSkillsQuery>(),
                       It.IsAny <CancellationToken>()))
            .ThrowsAsync(new InvalidOperationException());

            var controllerResult = await controller.GetSkills() as StatusCodeResult;

            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.InternalServerError);
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Adding the Category attribute to the Html markup for reference data lookup.
            ModelMetadataProviders.Current = new MetadataProvider();

            //Getting the reference data for the Html elements from the backend.
            ReferenceDataController referenceDataController = new ReferenceDataController();

            referenceDataDictionary = referenceDataController.getReferenceData();
        }
        public async Task When_Getting_Qualifications_Then_The_Query_Is_Made_And_Data_Returned(
            List <string> items,
            GetQualificationsQueryResponse response,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] ReferenceDataController controller)
        {
            response.Data = items;
            mockMediator
            .Setup(x => x.Send(It.IsAny <GetQualificationsQuery>(), CancellationToken.None))
            .ReturnsAsync(response);

            var actual = await controller.GetCandidateQualifications() as OkObjectResult;

            Assert.IsNotNull(actual);
            var actualResult = actual.Value as List <string>;

            actualResult.Should().BeEquivalentTo(items);
        }
Beispiel #6
0
        public async Task Then_Gets_Skills_From_Mediator(
            GetCandidateSkillsQueryResponse mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] ReferenceDataController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetCandidateSkillsQuery>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            var controllerResult = await controller.GetSkills() as ObjectResult;

            Assert.IsNotNull(controllerResult);
            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var model = controllerResult.Value as GetCandidateSkillsListResponse;

            Assert.IsNotNull(model);
            model.CandidateSkills.Should().BeEquivalentTo(mediatorResult.CandidateSkills);
        }