public async Task Fazer_Checkout_Com_Carrinho_Deveria_Publicar_CheckoutEvent()
        {
            //arrange
            var fakeClienteId       = "1";
            var fakeCarrinhoCliente = GetCarrinhoClienteFake(fakeClienteId);

            _carrinhoRepositoryMock.Setup(x => x.GetCarrinhoAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(fakeCarrinhoCliente))
            .Verifiable();

            //_identityServiceMock.Setup(x => x.GetUserIdentity()).Returns(fakeClienteId)
            //    .Verifiable();

            var carrinhoController = new CarrinhoController(
                _carrinhoRepositoryMock.Object, _identityServiceMock.Object, _serviceBusMock.Object);

            carrinhoController.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = new ClaimsPrincipal(
                        new ClaimsIdentity(new Claim[] { new Claim("unique_name", "testuser") }))
                }
            };

            //Act
            ActionResult <bool> actionResult = await carrinhoController.Checkout(fakeClienteId, new CadastroViewModel());

            //assert
            _serviceBusMock.Verify(mock => mock.Publish(It.IsAny <CheckoutEvent>(), null), Times.Once);
            Assert.NotNull(actionResult);
            _carrinhoRepositoryMock.Verify();
            //_identityServiceMock.Verify();
        }
        public async Task Fazer_Checkout_Carrinho_Not_Found()
        {
            //Arrange
            var fakeClienteId = "123";

            _carrinhoRepositoryMock.Setup(x => x.GetCarrinhoAsync(It.IsAny <string>()))
            .ThrowsAsync(new KeyNotFoundException());
            var carrinhoController = new CarrinhoController(
                _carrinhoRepositoryMock.Object,
                _identityServiceMock.Object,
                _serviceBusMock.Object);
            CadastroViewModel input = new CadastroViewModel();

            //Act
            ActionResult <bool> actionResult = await carrinhoController.Checkout(fakeClienteId, input);

            //Assert
            Assert.IsType <NotFoundResult>(actionResult.Result);
        }
        public async Task Fazer_Checkout_Sem_Cesta_Deve_Retornar_BadRequest()
        {
            //Arrange
            var fakeClienteId = "2";

            var carrinhoController = new CarrinhoController(
                _carrinhoRepositoryMock.Object,
                _identityServiceMock.Object,
                _serviceBusMock.Object);
            CadastroViewModel input = new CadastroViewModel();

            carrinhoController.ModelState.AddModelError("Email", "Required");

            //Act
            ActionResult <bool> actionResult = await carrinhoController.Checkout(fakeClienteId, input);

            //Assert
            BadRequestObjectResult badRequestObjectResult = Assert.IsType <BadRequestObjectResult>(actionResult.Result);

            Assert.IsAssignableFrom <SerializableError>(badRequestObjectResult.Value);
        }