Ejemplo n.º 1
0
        public void TestExecuteWithOneValueShouldReturnOneItemWithSameValues(string id, string nome, string canal, string valor, string obs)
        {
            //Arrange
            _contatoFromDB       = new Contato();
            _contatoFromDB.id    = new ObjectId(id);
            _contatoFromDB.nome  = nome;
            _contatoFromDB.canal = canal;
            _contatoFromDB.valor = valor;
            _contatoFromDB.obs   = obs;

            _resultFromDB = Task.FromResult(new List <Contato> {
                _contatoFromDB
            });

            _repository.Setup(x => x.GetByFilters(It.IsAny <List <Expression <Func <Contato, bool> > > >(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns(_resultFromDB);

            _query = new GetContatoListQuery(_repository.Object);

            //Act
            var result = _query.Execute(_filter).Result;

            //Assert
            Assert.Equal(id, result.First().id);
            Assert.Equal(nome, result.First().nome);
            Assert.Equal(canal, result.First().canal);
            Assert.Equal(valor, result.First().valor);
            Assert.Equal(obs, result.First().obs);
        }
Ejemplo n.º 2
0
        public void TestExecuteWithoutValuesShouldReturnListWithZeroItem()
        {
            _resultFromDB = Task.FromResult(new List <Contato> {
            });

            _repository.Setup(x => x.GetByFilters(It.IsAny <List <Expression <Func <Contato, bool> > > >(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns(_resultFromDB);

            _query = new GetContatoListQuery(_repository.Object);

            //Act
            var result = _query.Execute(_filter).Result;

            //Assert
            Assert.Empty(result);
        }
Ejemplo n.º 3
0
        public void TestExecuteWithOneValueShouldReturnListWithOneItem()
        {
            //Arrange
            var contato1 = new Contato {
                id = ObjectId.GenerateNewId(), nome = _str, canal = _str, valor = _str, obs = _str
            };

            _resultFromDB = Task.FromResult(new List <Contato> {
                contato1
            });

            _repository.Setup(x => x.GetByFilters(It.IsAny <List <Expression <Func <Contato, bool> > > >(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns(_resultFromDB);

            _query = new GetContatoListQuery(_repository.Object);

            //Act
            var result = _query.Execute(_filter).Result;

            //Assert
            Assert.Single(result);
        }