예제 #1
0
        public async Task CreateAsync_ReturnOkResult(double amaunt, string merchantId, TipoTransacaoEnum tipo)
        {
            var transacao = new TransacaoViewModel()
            {
                Amount = amaunt, MerchantId = merchantId, Type = tipo
            };

            // Arrange
            var mockServices = new Mock <ITransacaoAppServices>();

            mockServices.Setup(s => s.Insert(transacao));
            var controller = new FinancialOperationController();

            // Act
            var result = await controller.CreateAsync(transacao, mockServices.Object);

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(result);

            Assert.Equal(StatusCodes.Status201Created, okResult.Value);
        }
        public async Task CreateAsync_ReturnBadRequestResult(double amaunt, string merchantId, TipoTransacaoEnum tipo)
        {
            var transacao = new TransacaoViewModel()
            {
                Amount = amaunt, MerchantId = merchantId, Type = tipo
            };

            // Arrange
            var mockServices = new Mock <ITransacaoAppServices>();

            mockServices.Setup(s => s.Insert(transacao));
            var controller = new FinancialOperationController();

            controller.ModelState.AddModelError("Amaunt", "Deve ser informado maior que .10 centavos.");

            // Act
            var result = await controller.CreateAsync(transacao, mockServices.Object);

            // Assert
            var badRequest = Assert.IsType <BadRequestResult>(result);

            Assert.Equal(StatusCodes.Status400BadRequest, badRequest.StatusCode);
        }