예제 #1
0
        public void Controller_Contas_Put_DevePassar()
        {
            // Arrange
            var isUpdated = true;

            _contaServiceMock.Setup(c => c.Update(_contaUpdateCmd.Object)).Returns(isUpdated);
            // Action
            IHttpActionResult callback = _contasController.Put(_contaUpdateCmd.Object);
            // Assert
            var httpResponse = callback.Should().BeOfType <OkNegotiatedContentResult <bool> >().Subject;

            httpResponse.Content.Should().BeTrue();
            _contaServiceMock.Verify(s => s.Update(_contaUpdateCmd.Object), Times.Once);
        }
예제 #2
0
        public async Task UpdateBadRequest()
        {
            var serviceMock = new Mock <IContaService>();

            serviceMock.Setup(m => m.Put(It.IsAny <ContaDtoUpdate>())).ReturnsAsync(
                new ContaDtoUpdateResult
            {
                Id          = Guid.NewGuid(),
                Name        = "PV Conta",
                Description = "Conta Corrente",
                Balance     = 0,
                Status      = true,
                UpdateAt    = DateTime.Now
            }
                );

            _controller = new ContasController(serviceMock.Object);
            _controller.ModelState.AddModelError("Id", "Formato Inválido");

            var contaDtoUpdate = new ContaDtoUpdate
            {
                Id          = Guid.NewGuid(),
                Name        = "PV Conta",
                Description = "Conta Corrente",
                Status      = true
            };

            var result = await _controller.Put(contaDtoUpdate);

            Assert.True(result is BadRequestObjectResult);
        }