Example #1
0
        public void ApplicationServiceCliente_GetById_ShouldReturnClient()
        {
            //Arrange
            const int id = 10;

            var cliente = _fixture.Build <Cliente>()
                          .With(c => c.Id, id)
                          .With(c => c.Email, "*****@*****.**")
                          .Create();

            var clienteDto = _fixture.Build <ClienteDto>()
                             .With(c => c.Id, id)
                             .With(c => c.Email, "*****@*****.**")
                             .Create();

            _serviceClienteMock.Setup(x => x.GetById(id)).Returns(cliente);
            _mapperMock.Setup(x => x.Map <ClienteDto>(cliente)).Returns(clienteDto);

            var applicationServiceCliente =
                new ApplicationServiceCliente(_serviceClienteMock.Object, _mapperMock.Object);

            //Act
            var result = applicationServiceCliente.GetById(id);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("*****@*****.**", result.Email);
            Assert.AreEqual(10, result.Id);
            _serviceClienteMock.VerifyAll();
            _mapperMock.VerifyAll();
        }
Example #2
0
        public void ApplicationServiceCliente_GetAll_ShouldReturnFiveClients()
        {
            //Arrange
            var clientes    = _fixture.Build <Cliente>().CreateMany(5);
            var clientesDto = _fixture.Build <ClienteDto>().CreateMany(5);

            _serviceClienteMock.Setup(x => x.GetAll()).Returns(clientes);
            _mapperMock.Setup(x => x.Map <IEnumerable <ClienteDto> >(clientes)).Returns(clientesDto);

            var applicationServiceCliente = new ApplicationServiceCliente(_serviceClienteMock.Object, _mapperMock.Object);

            //Act
            var result = applicationServiceCliente.GetAll();

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(5, result.Count());
            _serviceClienteMock.VerifyAll();
            _mapperMock.VerifyAll();
        }