public async Task JobGroupPublishedRefreshServiceReloadItemForNonExistingJobGroupIsSuccessful()
        {
            // arrange
            const HttpStatusCode expectedResult = HttpStatusCode.OK;
            JobGroupModel?       nullJobGroup   = null;
            var getDetailResponse = new JobGroupModel
            {
                Soc   = 2,
                Title = "A title 2",
            };

            A.CallTo(() => fakeJobGroupApiConnector.GetDetailsAsync(A <Uri> .Ignored)).Returns(getDetailResponse);
            A.CallTo(() => fakeJobGroupDocumentService.GetAsync(A <Expression <Func <JobGroupModel, bool> > > .Ignored, A <string> .Ignored)).Returns(nullJobGroup);
            A.CallTo(() => fakeJobGroupDocumentService.UpsertAsync(A <JobGroupModel> .Ignored)).Returns(HttpStatusCode.OK);

            // act
            var result = await jobGroupPublishedRefreshService.ReloadItemAsync(new Uri("https://somewhere.com", UriKind.Absolute)).ConfigureAwait(false);

            // assert
            A.CallTo(() => fakeJobGroupApiConnector.GetDetailsAsync(A <Uri> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeJobGroupDocumentService.GetAsync(A <Expression <Func <JobGroupModel, bool> > > .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeJobGroupDocumentService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeJobGroupDocumentService.UpsertAsync(A <JobGroupModel> .Ignored)).MustHaveHappenedOnceExactly();

            Assert.Equal(expectedResult, result);
        }
        public async Task PagesControllerSideBarRightReturnsNoContentWhenNoData(string mediaTypeName)
        {
            // Arrange
            JobGroupModel?nullJobGroupModel = null;
            var           controller        = BuildPagesController(mediaTypeName);
            var           socRequestModel   = new SocRequestModel {
                Soc = 3231, FromJobProfileCanonicalName = "a-job-profile",
            };

            A.CallTo(() => FakeJobGroupDocumentService.GetAsync(A <Expression <Func <JobGroupModel, bool> > > .Ignored, A <string> .Ignored)).Returns(nullJobGroupModel);

            // Act
            var result = await controller.SideBarRight(socRequestModel).ConfigureAwait(false);

            // Assert
            A.CallTo(() => FakeJobGroupDocumentService.GetAsync(A <Expression <Func <JobGroupModel, bool> > > .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => FakeMapper.Map <SideBarRightViewModel>(A <JobGroupModel> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => FakeSharedContentDocumentService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).MustNotHaveHappened();

            var statusResult = Assert.IsType <NoContentResult>(result);

            A.Equals((int)HttpStatusCode.NoContent, statusResult.StatusCode);

            controller.Dispose();
        }
Ejemplo n.º 3
0
        public async Task JobGroupDataServiceGetSocReturnsNullForNoData()
        {
            // Arrange
            JobGroupModel?nullJobGroupModel = null;

            A.CallTo(() => fakeDraftJobGroupApiConnector.GetDetailAsync(A <Guid> .Ignored)).Returns(nullJobGroupModel);

            // Act
            var result = await jobGroupDataService.GetSocAsync(Guid.NewGuid()).ConfigureAwait(false);

            // Assert
            A.CallTo(() => fakeDraftJobGroupApiConnector.GetDetailAsync(A <Guid> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakePublishedJobGroupApiConnector.GetDetailAsync(A <int> .Ignored)).MustNotHaveHappened();
            Assert.Null(result);
        }
        public async Task JobGroupCacheRefreshServiceReloadItemReturnsBadRequest()
        {
            // arrange
            const HttpStatusCode expectedResult = HttpStatusCode.BadRequest;
            JobGroupModel? getDetailResponse = null;

            A.CallTo(() => fakeLmiTransformationApiConnector.GetDetailsAsync(A<Uri>.Ignored)).Returns(getDetailResponse);

            // act
            var result = await jobGroupCacheRefreshService.ReloadItemAsync(new Uri("https://somewhere.com", UriKind.Absolute)).ConfigureAwait(false);

            // assert
            A.CallTo(() => fakeLmiTransformationApiConnector.GetDetailsAsync(A<Uri>.Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeJobGroupDocumentService.GetAsync(A<Expression<Func<JobGroupModel, bool>>>.Ignored, A<string>.Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeJobGroupDocumentService.UpsertAsync(A<JobGroupModel>.Ignored)).MustNotHaveHappened();

            Assert.Equal(expectedResult, result);
        }
        public async Task PagesControllerDocumentReturnsNoContentWhenNoData(string mediaTypeName)
        {
            // Arrange
            JobGroupModel?expectedResult = null;
            var           controller     = BuildPagesController(mediaTypeName);

            A.CallTo(() => FakeJobGroupDocumentService.GetAsync(A <Expression <Func <JobGroupModel, bool> > > .Ignored, A <string> .Ignored)).Returns(expectedResult);

            // Act
            var result = await controller.Document(3231).ConfigureAwait(false);

            // Assert
            A.CallTo(() => FakeJobGroupDocumentService.GetAsync(A <Expression <Func <JobGroupModel, bool> > > .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly();

            var statusResult = Assert.IsType <NoContentResult>(result);

            A.Equals((int)HttpStatusCode.NoContent, statusResult.StatusCode);

            controller.Dispose();
        }
Ejemplo n.º 6
0
        public async Task LmiOrchestrationTriggerTransformItemAsyncReturnsBadRequestWhenNoItem()
        {
            // Arrange
            const HttpStatusCode expectedResult = HttpStatusCode.BadRequest;
            var           dummyLmiSoc           = A.Dummy <LmiSoc>();
            JobGroupModel?nullJobgroup          = null;

            A.CallTo(() => fakeCmsApiService.GetItemAsync <LmiSoc>(A <Uri> .Ignored)).Returns(dummyLmiSoc);
            A.CallTo(() => fakeMapper.Map <JobGroupModel?>(A <LmiSoc> .Ignored)).Returns(nullJobgroup);

            // Act
            var result = await lmiOrchestrationTrigger.TransformItemActivity(new Uri("https://somewhere.com", UriKind.Absolute)).ConfigureAwait(false);

            // Assert
            A.CallTo(() => fakeCmsApiService.GetItemAsync <LmiSoc>(A <Uri> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeMapper.Map <JobGroupModel?>(A <LmiSoc> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeJobGroupDocumentService.GetAsync(A <Expression <Func <JobGroupModel, bool> > > .Ignored, A <string> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => fakeJobGroupDocumentService.UpsertAsync(A <JobGroupModel> .Ignored)).MustNotHaveHappened();
            Assert.Equal(expectedResult, result);
        }