Exemple #1
0
        public async Task ChangeMethodicDocumentAsync(MethodicDocumentDTO documentDto)
        {
            MethodicDocument document = await _repoWrapper.MethodicDocument.GetFirstAsync(x => x.ID == documentDto.ID);

            document.Name        = documentDto.Name;
            document.Description = documentDto.Description;
            _repoWrapper.MethodicDocument.Update(document);
            await _repoWrapper.SaveAsync();
        }
        public async Task <IActionResult> Update(int id, MethodicDocumentDTO documentDTO)
        {
            if (id != documentDTO.ID)
            {
                return(BadRequest());
            }
            await _methodicDocService.ChangeMethodicDocumentAsync(documentDTO);

            return(NoContent());
        }
        public async Task <IActionResult> Get(int id)
        {
            MethodicDocumentDTO documentDto = await _methodicDocService.GetMethodicDocumentAsync(id);

            if (documentDto == null)
            {
                return(NotFound());
            }
            return(Ok(documentDto));
        }
        public async Task Update_ReturnsNoContentResult()
        {
            //Arrange
            var mockDoc = new MethodicDocumentDTO();

            _service
            .Setup(x => x.ChangeMethodicDocumentAsync(It.IsAny <MethodicDocumentDTO>()));

            //Act
            var result = await _controller.Update(It.IsAny <int>(), mockDoc);

            //Assert
            _service.Verify();
            Assert.IsInstanceOf <NoContentResult>(result);
        }
        public async Task Update_InvalidID()
        {
            //Arrange
            var expected = 1;
            var mockDoc  = new MethodicDocumentDTO();

            mockDoc.ID = 2;
            _service
            .Setup(x => x.ChangeMethodicDocumentAsync(mockDoc));

            //Act
            var result = await _controller.Update(expected, mockDoc);

            //Assert
            _service.Verify();
            Assert.IsInstanceOf <BadRequestResult>(result);
        }
Exemple #6
0
        public async Task ChangeMethodicDocumentAsync_Valid_Test(string docNewName, string docnNewDescription)
        {
            //Arrange
            _repository.Setup(rep => rep.MethodicDocument.GetFirstAsync(It.IsAny <Expression <Func <MethodicDocument, bool> > >(),
                                                                        It.IsAny <Func <IQueryable <MethodicDocument>, IIncludableQueryable <MethodicDocument, object> > >()))
            .ReturnsAsync(GetTestDocsQueryable().FirstOrDefault());

            //Act
            var DocsDto = new MethodicDocumentDTO();

            DocsDto.Name        = docNewName;
            DocsDto.Description = docnNewDescription;
            await _service.ChangeMethodicDocumentAsync(DocsDto);

            //Assert
            _repository.Verify(rep => rep.MethodicDocument.GetFirstAsync(It.IsAny <Expression <Func <MethodicDocument, bool> > >(),
                                                                         It.IsAny <Func <IQueryable <MethodicDocument>, IIncludableQueryable <MethodicDocument, object> > >()), Times.Once);
        }