8.1.3.4 Highlighting the Current Category; UNIT TEST: REPORTING THE SELECTED CATEGORY
parent
32fa22777d
commit
6cc688fc9d
|
@ -149,5 +149,30 @@ namespace SportsStore.UnitTests
|
|||
Assert.AreEqual(results[1], "Oranges");
|
||||
Assert.AreEqual(results[2], "Plums");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Indicates_Selected_Category()
|
||||
{
|
||||
// Arrange
|
||||
// - create the mock repository
|
||||
Mock<IProductRepository> mock = new Mock<IProductRepository>();
|
||||
mock.Setup(m => m.Products).Returns(new Product[]
|
||||
{
|
||||
new Product { ProductID = 1, Name = "P1", Category = "Apples" },
|
||||
new Product { ProductID = 4, Name = "P2", Category = "Oranges" },
|
||||
});
|
||||
|
||||
// Arrange - create the controller
|
||||
NavController target = new NavController(mock.Object);
|
||||
|
||||
// Arrange - define the category to selected
|
||||
string categoryToSelected = "Apples";
|
||||
|
||||
// Action
|
||||
string result = target.Menu(categoryToSelected).ViewBag.SelectedCategory;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(categoryToSelected, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue