So, I'm working on some unit tests, and don't understand why this is happening...
That's the method I am trying to test:
public IEnumerable<Produtos> GetAll(string term, int page, int pageSize)
{
var products = _repository.GetAllProducts().ToList();
List<Produtos> produtos = new List<Produtos>();
products.ForEach(produto =>
{
if (produto.Nome.Contains(term))
{
produtos.Add(produto);
}
}
);
if (!(produtos.Count > 0))
{
throw new Exception();
}
return produtos.Skip((page - 1) * pageSize).Take(pageSize);
}
That is the Test Class I wrote:
[TestClass]
public class ProductTests
{
private readonly ProductsService _service;
public ProductTests()
{
_service = new ProductsService();
}
[TestMethod]
public void GetAll_RequestProducts_ReturnsProduts()
{
var result = _service.GetAll("camisa", 1, 1);
Assert.IsNotNull(result);
}
}
and those are the results: