示例#1
0
        public async Task ReturnsSuccessForHtmlMediaType(string mediaTypeName)
        {
            // Arrange
            var controller = BuildSegmentController(mediaTypeName);
            var dbModels   = GetSegmentModels();

            A.CallTo(() => FakeCurrentOpportunitiesSegmentService.GetAllAsync()).Returns(dbModels);

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

            // Assert
            A.CallTo(() => FakeJobProfileSegmentRefreshService.SendMessageListAsync(A <List <RefreshJobProfileSegmentServiceBusModel> > .Ignored)).MustHaveHappenedOnceExactly();
            var res = Assert.IsType <JsonResult>(result);

            Assert.Equal(dbModels.Count, (res.Value as List <RefreshJobProfileSegmentServiceBusModel>).Count);

            controller.Dispose();
        }
示例#2
0
        public async Task ReturnsNoContentWhenNoData(string mediaTypeName)
        {
            // Arrange
            List <CurrentOpportunitiesSegmentModel> expectedResult = null;
            var controller = BuildSegmentController(mediaTypeName);

            A.CallTo(() => FakeCurrentOpportunitiesSegmentService.GetAllAsync()).Returns(expectedResult);

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

            // Assert
            A.CallTo(() => FakeJobProfileSegmentRefreshService.SendMessageListAsync(A <List <RefreshJobProfileSegmentServiceBusModel> > .Ignored)).MustNotHaveHappened();
            var statusResult = Assert.IsType <NoContentResult>(result);

            A.CallTo(() => FakeLogger.LogWarning(A <string> .Ignored)).MustHaveHappenedOnceExactly();
            Assert.Equal((int)HttpStatusCode.NoContent, statusResult.StatusCode);

            controller.Dispose();
        }
        public async Task SegmentControllerIndexHtmlReturnsSuccessWhenNoData(string mediaTypeName)
        {
            // Arrange
            const int resultsCount = 0;
            IEnumerable <CurrentOpportunitiesSegmentModel> expectedResults = null;
            var controller = BuildSegmentController(mediaTypeName);

            A.CallTo(() => FakeCurrentOpportunitiesSegmentService.GetAllAsync()).Returns(expectedResults);
            A.CallTo(() => FakeMapper.Map <IndexDocumentViewModel>(A <CurrentOpportunitiesSegmentModel> .Ignored)).Returns(A.Fake <IndexDocumentViewModel>());

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

            // Assert
            A.CallTo(() => FakeCurrentOpportunitiesSegmentService.GetAllAsync()).MustHaveHappenedOnceExactly();
            A.CallTo(() => FakeMapper.Map <IndexDocumentViewModel>(A <CurrentOpportunitiesSegmentModel> .Ignored)).MustHaveHappened(resultsCount, Times.Exactly);

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <IndexViewModel>(viewResult.ViewData.Model);

            Assert.Null(model.Documents);

            controller.Dispose();
        }