Example #1
0
        public void CreateWithValidVeiculoShouldReturnAluguel()
        {
            // Arrange
            var id         = 0;
            var veiculo    = new Veiculo("IKG6861", "Verde", 100.00, true, true, "Hyundai", "HB20", TipoVeiculo.Carro, "Aluguel");
            var aluguelDto = new AluguelDto
            {
                IdVeiculo    = id,
                ValorMensal  = 100,
                Nome         = "Comprador",
                DataEntrega  = DateTime.Now,
                DataRetirada = DateTime.Now
            };

            var aluguel = new Aluguel(id, 100, "Comprador", DateTime.Now, DateTime.Now);

            veiculoRepository.GetById(id).Returns(veiculo);
            aluguelRepository.CreateAluguel(aluguelDto).Returns(aluguel);

            // Act
            var result = service.Create(aluguelDto);

            // Assert
            result.Should().NotBeNull();
            result.Should().Equals(aluguel);
            aluguelRepository.Received().CreateAluguel(aluguelDto);
        }
Example #2
0
        public IActionResult Create([FromBody] AluguelDto aluguelDto)
        {
            var result = service.Create(aluguelDto);

            return(Ok(result));
        }