Creating the Second Test

In this test, we would like to test our controller to call just the desired Genre of our product collections.

First thing first, create a new TestMethod. Just copy from previous repository's mock and add a new Product with different genre.

[TestMethod]
public void FindGenreReturnsAllInGenre()
{
    // Arrange
    var productRepository = Mock.Create<Repository>();
    Mock.Arrange(() => productRepository.GetAll()).
        Returns(new List<Product>()
        {
            new Product { Genre = "Fiction", Id = 1, Name = "Hunger Games", Price = 200000},
            new Product { Genre = "Fiction", Id = 2, Name = "Hunger Games 2", Price = 300000},
            new Product { Genre = "Mistery", Id = 3, Name = "The Pilgrimage", Price = 400000}
        }).MustBeCalled();

    // Act

    // Assert

}

results matching ""

    No results matching ""