Esempio n. 1
0
        public void TransferConflictObjectResult()
        {
            _transfer.Origin = null;
            _transferService.Setup(x => x.Transfer(_transfer)).Throws <Exception>();

            var callback = _transferController.Post(_transfer);

            Assert.IsAssignableFrom <ConflictObjectResult>(callback);
        }
        public async Task Should_Error_Create_Data()
        {
            var validateMock = new Mock <IValidateService>();

            validateMock.Setup(s => s.Validate(It.IsAny <TransferInDocViewModel>())).Verifiable();

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <TransferInDoc>(It.IsAny <TransferInDocViewModel>()))
            .Returns(Model);

            var mockFacade = new Mock <ITransferInDoc>();

            mockFacade.Setup(x => x.Create(It.IsAny <TransferInDoc>(), "unittestusername", 7))
            .ReturnsAsync(1);

            var controller = new TransferController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object);

            var response = await controller.Post(this.ViewModel);

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }