public void GetDocumentsEmptyContextNotFound()
        {
            using (var context = DbTestContext.GenerateEmptyContext())
                using (var controller = new DocumentsController(context, _mapper))
                {
                    var result = controller.GetDocuments();

                    Assert.IsType <NotFoundResult>(result);
                }
        }
        public async Task GetDocuments_Success()
        {
            //Arrange------------------------------------------------------------------------------------------------------------------------------
            //_mockRepo.Setup(x => x.DocumentRepository.GetManyAsync(
            //        It.IsAny<Expression<Func<Document, bool>>>(),
            //        It.IsAny<Func<IQueryable<Document>, IOrderedQueryable<Document>>>(),
            //        It.IsAny<string>()))
            //    .ReturnsAsync(new List<Document>());

            _mockMapper.Setup(x => x.Map <List <DocumentForReturnDto> >(It.IsAny <List <Document> >()))
            .Returns(new List <DocumentForReturnDto>());

            //Act----------------------------------------------------------------------------------------------------------------------------------
            var result = await _controller.GetDocuments(It.IsAny <string>());

            var okResult = result as OkObjectResult;

            //Assert-------------------------------------------------------------------------------------------------------------------------------
            Assert.NotNull(okResult);
            Assert.Equal(200, okResult.StatusCode);
        }
        public void GetDocumentsReturnsListOfDocuments()
        {
            using (var context = DbTestContext.GenerateContextWithData())
                using (var controller = new DocumentsController(context, _mapper))
                {
                    var         result = controller.GetDocuments();
                    DocumentDto d3     = GetTestDocumentDtoFromContext(3);

                    Assert.NotNull(result);
                    var okObjectResult = Assert.IsType <OkObjectResult>(result);
                    var resultValue    = okObjectResult.Value;
                    Assert.IsAssignableFrom <IEnumerable <DocumentDto> >(resultValue);
                    Assert.NotEmpty((IEnumerable <DocumentDto>)resultValue);

                    IEnumerable <DocumentDto> resultValueList = (IEnumerable <DocumentDto>)resultValue;

                    DocumentDto d = (DocumentDto)resultValueList.Single(r => r.Id == 3);
                    Assert.True(d.Equals(d3));
                    Assert.True(d.Equals(d3, true));
                }
        }
示例#4
0
        public void GetDocuments_ReturnsAllGeneralDocuments()
        {
            var result = _controller.GetDocuments();

            Assert.AreEqual(3, result.Count());
        }