public void Can_Create_Categories() { Mock <IBookRepository> mock = new Mock <IBookRepository>(); mock.Setup(m => m.Books).Returns(new List <Book> { new Book { BookId = 1, Name = "Book1", Genre = "Genre1" }, new Book { BookId = 2, Name = "Book2", Genre = "Genre2" }, new Book { BookId = 3, Name = "Book3", Genre = "Genre1" }, new Book { BookId = 4, Name = "Book4", Genre = "Genre3" }, new Book { BookId = 5, Name = "Book5", Genre = "Genre2" } }); NavController target = new NavController(mock.Object); List <string> result = ((IEnumerable <string>)target.Menu().Model).ToList(); Assert.AreEqual(result.Count(), 3); Assert.AreEqual(result[0], "Genre1"); Assert.AreEqual(result[1], "Genre2"); Assert.AreEqual(result[2], "Genre3"); }
public void Indicates_Selected_Genre() { Mock <IBookRepository> mock = new Mock <IBookRepository>(); mock.Setup(m => m.Books).Returns(new List <Book> { new Book { BookId = 1, Name = "Book1", Genre = "Genre1" }, new Book { BookId = 2, Name = "Book2", Genre = "Genre2" }, new Book { BookId = 3, Name = "Book3", Genre = "Genre1" }, new Book { BookId = 4, Name = "Book4", Genre = "Genre3" }, new Book { BookId = 5, Name = "Book5", Genre = "Genre2" } }); NavController target = new NavController(mock.Object); string genreToSelect = "Genre2"; string result = target.Menu(genreToSelect).ViewBag.SelectedGenre; Assert.AreEqual(genreToSelect, result); }
public void Can_Create_Categories() { Mock <IGameRepository> mock = new Mock <IGameRepository>(); mock.Setup(m => m.Games).Returns(new List <Game> { new Game { GameId = 1, Name = "Игра1", Category = "Симулятор" }, new Game { GameId = 2, Name = "Игра2", Category = "Симулятор" }, new Game { GameId = 3, Name = "Игра3", Category = "Шутер" }, new Game { GameId = 4, Name = "Игра4", Category = "RPG" }, }); NavController target = new NavController(mock.Object); List <string> results = ((IEnumerable <string>)target.Menu().Model).ToList(); Assert.AreEqual(results.Count(), 3); Assert.AreEqual(results[0], "RPG"); Assert.AreEqual(results[1], "Симулятор"); Assert.AreEqual(results[2], "Шутер"); }
public void Indicates_Selected_Category() { Mock <IGameRepository> mock = new Mock <IGameRepository>(); mock.Setup(m => m.Games).Returns(new Game[] { new Game { GameId = 1, Name = "Игра1", Category = "Симулятор" }, new Game { GameId = 2, Name = "Игра2", Category = "Шутер" } }); NavController target = new NavController(mock.Object); string categoryToSelect = "Шутер"; string result = target.Menu(categoryToSelect).ViewBag.SelectedCategory; Assert.AreEqual(categoryToSelect, result); }
public void Can_Create_Category() { Mock <IPartsRepository> mock = new Mock <IPartsRepository>(); mock.Setup(m => m.Parts).Returns(new List <Part> { new Part { PartId = 1, Name = "Part1", Category = "Category1" }, new Part { PartId = 2, Name = "Part2", Category = "Category2" }, new Part { PartId = 3, Name = "Part3", Category = "Category1" }, new Part { PartId = 4, Name = "Part4", Category = "Category3" }, new Part { PartId = 5, Name = "Part5", Category = "Category2" } }); NavController target = new NavController(mock.Object); List <string> result = ((IEnumerable <string>)target.Menu().Model).ToList(); Assert.AreEqual(result.Count(), 3); Assert.AreEqual(result[0], "Category1"); Assert.AreEqual(result[1], "Category2"); Assert.AreEqual(result[2], "Category3"); }
public void Indicates_Selected_Category() { // Организация (arrange) Mock <IPartsRepository> mock = new Mock <IPartsRepository>(); mock.Setup(m => m.Parts).Returns(new List <Part> { new Part { PartId = 1, Name = "{Part1", Category = "Category1" }, new Part { PartId = 2, Name = "{Part2", Category = "Category2" }, new Part { PartId = 3, Name = "{Part3", Category = "Category1" }, new Part { PartId = 4, Name = "{Part4", Category = "Category3" }, new Part { PartId = 5, Name = "{Part5", Category = "Category2" } }); NavController target = new NavController(mock.Object); string catToSelect = "Category2"; // Действие (act) string result = target.Menu(catToSelect).ViewBag.SelectedCategory; Assert.AreEqual(catToSelect, result); }
public void TestMethod1() { //Arrange Mock <IProductRepository> mock = new Mock <IProductRepository>(); mock.Setup(s => s.Products).Returns(new Product[] { new Product { ProductID = 1, Name = "P1" }, new Product { ProductID = 2, Name = "P2" }, new Product { ProductID = 3, Name = "P3" }, new Product { ProductID = 4, Name = "P4" }, }); NavController nav = new NavController(mock.Object); //act //string[] s = nav.Menu().Model.s string[] results = ((IEnumerable <string>)(nav.Menu().Model)).ToArray(); // arrange // Assert Assert.AreEqual(results.Length, 3); Assert.AreEqual(results[0], "Apples"); Assert.AreEqual(results[1], "Oranges"); Assert.AreEqual(results[2], "Plums"); }
public void Indicates_Selected_Spec() { //Arrange Mock <IBookRepository> mock = new Mock <IBookRepository>(); mock.Setup(b => b.Books).Returns( new Book[] { new Book { ISBN = 1, Title = "Operating System", Specialization = "CS" }, new Book { ISBN = 2, Title = "Database System", Specialization = "IS" }, new Book { ISBN = 3, Title = "Database System", Specialization = "IS" }, new Book { ISBN = 4, Title = "System", Specialization = "IS" }, new Book { ISBN = 5, Title = "IS", Specialization = "IS" } }); NavController controller = new NavController(mock.Object); //Act string result = controller.Menu("IS").ViewBag.SelectedSpec; //Assert Assert.AreEqual("IS", result); }
public void Can_Create_Categories() { // arrage Mock <IProductRepository> mock = new Mock <IProductRepository>(); mock.Setup(m => m.Products).Returns(new Product[] { new Product { ProductId = 1, Name = "P1", Category = "Jabłka" }, new Product { ProductId = 2, Name = "P2", Category = "Jabłka" }, new Product { ProductId = 3, Name = "P3", Category = "Śliwki" }, new Product { ProductId = 4, Name = "P4", Category = "Pomarańcze" } }.AsQueryable()); NavController target = new NavController(mock.Object); //act //munu to nazwa Akcji string[] result = ((IEnumerable <string>)target.Menu().Model).ToArray(); //assert Assert.AreEqual(result.Length, 3); Assert.AreEqual(result[0], "Jabłka"); Assert.AreEqual(result[1], "Pomarańcze"); Assert.AreEqual(result[2], "Śliwki"); }
public void Can_Create_Categories() { //Arrange Mock <IPhoneRepository> mock = new Mock <IPhoneRepository>(); mock.Setup(m => m.Phones).Returns(new List <Phone> { new Phone { PhoneId = 1, Name = "Phone1", Category = "Samsung" }, new Phone { PhoneId = 2, Name = "Phone2", Category = "Samsung" }, new Phone { PhoneId = 3, Name = "Phone3", Category = "Apple" }, new Phone { PhoneId = 4, Name = "Phone4", Category = "Meizu" }, new Phone { PhoneId = 5, Name = "Phone5", Category = "Xiaomi" }, }); NavController target = new NavController(mock.Object); //Act List <string> results = ((IEnumerable <string>)target.Menu().Model).ToList(); //Assert Assert.AreEqual(results.Count(), 4); Assert.AreEqual(results[0], "Apple"); Assert.AreEqual(results[1], "Meizu"); Assert.AreEqual(results[2], "Samsung"); Assert.AreEqual(results[3], "Xiaomi"); }
public void MenuTest1() { //Arrange Mock <IProductsRepository> mock = new Mock <IProductsRepository>(); mock.Setup(m => m.Products).Returns(new Product[] { new Product { ProductID = 1, Name = "p1", Category = "1" }, new Product { ProductID = 2, Name = "p2", Category = "1" }, new Product { ProductID = 3, Name = "p3", Category = "3" }, new Product { ProductID = 4, Name = "p4", Category = "2" }, }.AsQueryable()); NavController target = new NavController(mock.Object); //Act string[] results = ((IEnumerable <string>)target.Menu().Model).ToArray(); //Assert Assert.AreEqual(3, results.Length); Assert.AreEqual(results[0], "1"); Assert.AreEqual(results[1], "2"); Assert.AreEqual(results[2], "3"); }
public void TestIndicatesSelectedCategory() { // Preparation - Create moke db 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 = 2, Name = "P2", Category = "Oranges" } }); // Preparation - create controller NavController target = new NavController(mock.Object); // Preparation - create selected category string categoryToSelect = "Apples"; // Action string result = target.Menu(categoryToSelect).ViewBag.SelectedCategory; // Assertions Assert.AreEqual(categoryToSelect, result); }
public void TestCanCreateCategories() { // Preparation - Create moke db 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 = 2, Name = "P2", Category = "Apples" }, new Product { ProductID = 3, Name = "P3", Category = "Plums" }, new Product { ProductID = 4, Name = "P4", Category = "Oranges" } }); // Preparation - create controller NavController target = new NavController(mock.Object); // Action - get categories string[] results = ((IEnumerable <string>)target.Menu().Model).ToArray(); // Assertions Assert.AreEqual(results.Length, 3); Assert.AreEqual(results[0], "Apples"); Assert.AreEqual(results[1], "Oranges"); Assert.AreEqual(results[2], "Plums"); }
public void Indicates_Selected_Category() { // Организация - создание имитированного хранилища Mock <IGameRepository> mock = new Mock <IGameRepository>(); mock.Setup(m => m.Games).Returns(new Game[] { new Game { GameId = 1, Name = "Игра1", Category = "Симулятор" }, new Game { GameId = 2, Name = "Игра2", Category = "Шутер" } }); // Организация - создание контроллера NavController target = new NavController(mock.Object); // Организация - определение выбранной категории string categoryToSelect = "Шутер"; // Действие string result = target.Menu(categoryToSelect).ViewBag.SelectedCategory; // Утверждение Assert.AreEqual(categoryToSelect, result); }
public void Indicates_Seceted_Category() { // 准备 创建模仿存储库 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 = "P4", Category = "Oranges" }, }); // 准备-创建控制器 NavController target = new NavController(mock.Object); // 准备已选分类 string categoryToSecelt = "Apples"; //动作--获取分类集合 string results = target.Menu(categoryToSecelt).ViewBag.SelectedCategory; // 断言 Assert.AreEqual(categoryToSecelt, results); }
public void Can_Create_Categories() { // Организация - создание имитированного хранилища Mock <IGameRepository> mock = new Mock <IGameRepository>(); mock.Setup(m => m.Games).Returns(new List <Game> { new Game { GameId = 1, Name = "Игра1", Category = "Симулятор" }, new Game { GameId = 2, Name = "Игра2", Category = "Симулятор" }, new Game { GameId = 3, Name = "Игра3", Category = "Шутер" }, new Game { GameId = 4, Name = "Игра4", Category = "RPG" }, }); // Организация - создание контроллера NavController target = new NavController(mock.Object); // Действие - получение набора категорий List <string> results = ((IEnumerable <string>)target.Menu().Model).ToList(); // Утверждение Assert.AreEqual(results.Count(), 3); Assert.AreEqual(results[0], "RPG"); Assert.AreEqual(results[1], "Симулятор"); Assert.AreEqual(results[2], "Шутер"); }
public void Can_Create_Categories() { // 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 = 2, Name = "P2", Category = "Apples" }, new Product { ProductID = 3, Name = "P3", Category = "Plums" }, new Product { ProductID = 4, Name = "P4", Category = "Oranges" }, }.AsQueryable()); // Arrange - create the controller NavController target = new NavController(mock.Object); // Act = get the set of categories string[] results = ((IEnumerable <string>)target.Menu().Model).ToArray(); // Assert Assert.AreEqual(results.Length, 3); Assert.AreEqual(results[0], "Apples"); Assert.AreEqual(results[1], "Oranges"); Assert.AreEqual(results[2], "Plums"); }
public void Can_Create_Categories() { // 准备 创建模仿存储库 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 = 2, Name = "P2", Category = "Apples" }, new Product { ProductID = 3, Name = "P3", Category = "Plums" }, new Product { ProductID = 4, Name = "P4", Category = "Oranges" }, }); // 准备-创建控制器 NavController target = new NavController(mock.Object); //动作--获取分类集合 string[] results = ((IEnumerable <string>)target.Menu().Model).ToArray(); // 断言 Assert.AreEqual(results.Length, 3); Assert.AreEqual(results[0], "Apples"); Assert.AreEqual(results[1], "Oranges"); Assert.AreEqual(results[2], "Plums"); }
public void Can_Create_Categories() { //Arrange Mock <IAutoRepository> mock = new Mock <IAutoRepository>(); mock.Setup(m => m.Autos).Returns(new List <Auto> { new Auto { Id = 1, Name = "AUDI", Type = "Type1" }, new Auto { Id = 2, Name = "BENTLEY", Type = "Type2" }, new Auto { Id = 3, Name = "BMW", Type = "Type1" }, new Auto { Id = 4, Name = "FERRARI", Type = "Type3" }, new Auto { Id = 5, Name = "HYUNDAI", Type = "Type2" }, }); NavController target = new NavController(mock.Object); //Act List <string> result = ((IEnumerable <string>)target.Menu().Model).ToList(); Assert.AreEqual(result.Count(), 3); Assert.AreEqual(result[0], "Type1"); Assert.AreEqual(result[1], "Type2"); Assert.AreEqual(result[2], "Type3"); }
public void Indicates_Selected_Type() { //Arrange Mock <IAutoRepository> mock = new Mock <IAutoRepository>(); mock.Setup(m => m.Autos).Returns(new List <Auto> { new Auto { Id = 1, Name = "AUDI", Type = "Type1" }, new Auto { Id = 2, Name = "BENTLEY", Type = "Type2" }, new Auto { Id = 3, Name = "BMW", Type = "Type1" }, new Auto { Id = 4, Name = "FERRARI", Type = "Type3" }, new Auto { Id = 5, Name = "HYUNDAI", Type = "Type2" }, }); NavController target = new NavController(mock.Object); string TypeToSelect = "Type2"; //Act string result = target.Menu(TypeToSelect).ViewBag.SelectedType; Assert.AreEqual(TypeToSelect, result); }
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 categoryToSelect = "Apples"; // Action string result = target.Menu(categoryToSelect).ViewBag.SelectedCategory; // Assert Assert.AreEqual(categoryToSelect, result); }
public void Can_Create_Categories() { Mock <IProductRepository> mock = new Mock <IProductRepository>(); mock.Setup(m => m.Products).Returns(new Product[] { new Product { ProductID = 1, Name = "p1", Category = "jabłka" }, new Product { ProductID = 2, Name = "p2", Category = "jabłka" }, new Product { ProductID = 3, Name = "p3", Category = "śliwki" }, new Product { ProductID = 4, Name = "p4", Category = "pomarańcze" }, }); NavController target = new NavController(mock.Object); string[] result = ((IEnumerable <string>)target.Menu().Model).ToArray(); Assert.AreEqual(result.Length, 3); Assert.AreEqual(result[0], "jabłka"); Assert.AreEqual(result[1], "pomarańcze"); Assert.AreEqual(result[2], "śliwki"); }
public void Indicates_Selected_Category() { Mock <IProductRepository> mock = new Mock <IProductRepository>(); mock.Setup(m => m.Products).Returns(new Product[] { new Product { ProductID = 1, Name = "P1", Category = "Cat1" }, new Product { ProductID = 2, Name = "P2", Category = "Cat2" }, new Product { ProductID = 3, Name = "P3", Category = "Cat1" }, new Product { ProductID = 4, Name = "P4", Category = "Cat2" }, new Product { ProductID = 5, Name = "P5", Category = "Cat1" }, new Product { ProductID = 6, Name = "P6", Category = "Cat3" } }.AsQueryable); NavController target = new NavController(mock.Object); string categoryToSelect = "Cat1"; string result = target.Menu(categoryToSelect).ViewBag.SelectedCategory; Assert.AreEqual(categoryToSelect, result); }
public void Can_Create_Categories() { Mock <IProductsRepository> mock = new Mock <IProductsRepository>(); mock.Setup(m => m.Products).Returns(new Product[] { new Product() { ProductID = 1, Name = "P1", Category = "Apples" }, new Product() { ProductID = 2, Name = "P2", Category = "Apples" }, new Product() { ProductID = 3, Name = "P3", Category = "Plums" }, new Product() { ProductID = 4, Name = "P4", Category = "Oranges" }, }); NavController target = new NavController(mock.Object); string[] results = ((IEnumerable <string>)target.Menu().Model).ToArray(); Assert.AreEqual(results.Length, 3); Assert.AreEqual("Apples", results[0]); Assert.AreEqual("Oranges", results[1]); Assert.AreEqual("Plums", results[2]); }
public void Indicates_Selected_Type() { //Організація (arrange) Mock <ISweetRepository> mock = new Mock <ISweetRepository>(); mock.Setup(m => m.Sweets).Returns(new List <Sweet> { new Sweet { SweetId = 1, Name = "Sweet1", Type = "Type1" }, new Sweet { SweetId = 2, Name = "Sweet2", Type = "Type2" }, new Sweet { SweetId = 3, Name = "Sweet3", Type = "Type1" }, new Sweet { SweetId = 4, Name = "Sweet4", Type = "Type3" }, new Sweet { SweetId = 5, Name = "Sweet5", Type = "Type2" } }); NavController target = new NavController(mock.Object); string typeToSelect = "Type2"; //Дія (act) string result = target.Menu(typeToSelect).ViewBag.SelectedType; Assert.AreEqual(typeToSelect, result); }
public void Can_Create_Categories() { Mock <IProductRepository> mock = new Mock <IProductRepository>(); mock.Setup(m => m.Products).Returns(new Product[] { new Product { ProductID = 1, Name = "P1", Category = "Cat1" }, new Product { ProductID = 2, Name = "P2", Category = "Cat2" }, new Product { ProductID = 3, Name = "P3", Category = "Cat1" }, new Product { ProductID = 4, Name = "P4", Category = "Cat2" }, new Product { ProductID = 5, Name = "P5", Category = "Cat1" }, new Product { ProductID = 6, Name = "P6", Category = "Cat3" } }.AsQueryable); NavController target = new NavController(mock.Object); string[] result = ((IEnumerable <string>)target.Menu().Model).ToArray(); Assert.AreEqual(result.Length, 3); Assert.AreEqual(result[0], "Cat1"); Assert.AreEqual(result[1], "Cat2"); Assert.AreEqual(result[2], "Cat3"); }
public void Can_Create_Categories() { //Організація (arrange) Mock <ISweetRepository> mock = new Mock <ISweetRepository>(); mock.Setup(m => m.Sweets).Returns(new List <Sweet> { new Sweet { SweetId = 1, Name = "Sweet1", Type = "Type1" }, new Sweet { SweetId = 2, Name = "Sweet2", Type = "Type2" }, new Sweet { SweetId = 3, Name = "Sweet3", Type = "Type1" }, new Sweet { SweetId = 4, Name = "Sweet4", Type = "Type3" }, new Sweet { SweetId = 5, Name = "Sweet5", Type = "Type2" } }); NavController target = new NavController(mock.Object); //Дія (act) List <string> result = ((IEnumerable <string>)target.Menu().Model).ToList(); Assert.AreEqual(result.Count(), 3); Assert.AreEqual(result[0], "Type1"); Assert.AreEqual(result[1], "Type2"); Assert.AreEqual(result[2], "Type3"); }
public void Can_Create_Category() { //Arrange 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 = 2, Name = "P2", Category = "Apples" }, new Product { ProductID = 3, Name = "P3", Category = "Chess" }, new Product { ProductID = 4, Name = "P4", Category = "Chess" }, new Product { ProductID = 5, Name = "P5", Category = "Plums" }, new Product { ProductID = 6, Name = "P6", Category = "Plums" } }.AsQueryable()); NavController controller = new NavController(mock.Object); //Action string[] result = ((IEnumerable <string>)controller.Menu().Model).ToArray(); //Assert Assert.AreEqual(result.Length, 3); Assert.AreEqual(result[0], "Apples"); }
public void Indicates_Selected_Category() { // Организация - создание имитированного хранилища Mock <IActivityRepository> mock = new Mock <IActivityRepository>(); ActivityType type1 = new ActivityType { ActivityTypeId = Guid.NewGuid(), ActivityTypeTitle = "Один" }; ActivityType type2 = new ActivityType { ActivityTypeId = Guid.NewGuid(), ActivityTypeTitle = "Два" }; mock.Setup(m => m.Activities).Returns(new List <Activity> { new Activity { ActivityId = Guid.NewGuid(), ActivityName = "Игра1", ActivityTypeCurrent = type1 }, new Activity { ActivityId = Guid.NewGuid(), ActivityName = "Игра2", ActivityTypeCurrent = type2 }, }); // Организация - создание контроллера NavController target = new NavController(mock.Object); // Организация - определение выбранной категории string categoryToSelect = "Два"; // Действие string result = target.Menu(categoryToSelect).ViewBag.SelectedCategory; // Утверждение Assert.AreEqual(categoryToSelect, result); }
public void Can_Create_Categories() { //Arrange 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 = 2, Name = "P2", Category = "Oranges" }, new Product { ProductId = 3, Name = "P3", Category = "Apples" }, new Product { ProductId = 4, Name = "P4", Category = "Cocos" }, new Product { ProductId = 5, Name = "P5", Category = "Apples" }, }.AsQueryable()); //Arrange NavController target = new NavController(mock.Object); //Act string[] result = ((IEnumerable <string>)target.Menu().Model).ToArray(); //Assert Assert.AreEqual(result.Length, 3); Assert.AreEqual(result[0], "Apples"); Assert.AreEqual(result[1], "Cocos"); Assert.AreEqual(result[2], "Oranges"); }
public void Indicates_Selected_Category() { Mock<IPubRepository> mock = new Mock<IPubRepository>(); mock.Setup(m => m.Pubs).Returns(new Pub[] { new Pub {PubId = 1, Name = "P1", Category = "Apples" }, new Pub {PubId = 4, Name = "P2", Category = "Oranges" } }); NavController target = new NavController(mock.Object); string categoryToSelect = "Apples"; string result = target.Menu(categoryToSelect).ViewBag.SelectedCategory; Assert.AreEqual(categoryToSelect, result); }
public void Can_Create_Categories() { Mock<IPubRepository> mock = new Mock<IPubRepository>(); mock.Setup(m => m.Pubs).Returns(new Pub[] { new Pub {PubId = 1, Name = "P1", Category = "Apples" }, new Pub {PubId = 2, Name = "P2", Category = "Apples" }, new Pub {PubId = 3, Name = "P3", Category = "Plums" }, new Pub {PubId = 4, Name = "P4", Category = "Oranges" } }); NavController target = new NavController(mock.Object); string[] results = ((IEnumerable<string>)target.Menu().Model).ToArray(); Assert.AreEqual(results.Length, 3); Assert.AreEqual(results[0], "Apples"); Assert.AreEqual(results[1], "Oranges"); Assert.AreEqual(results[2], "Plums"); }
public void Indicates_Selected_Category() { // Arrange // - create the mock repository Mock<IShoeStoreRepository> mock = new Mock<IShoeStoreRepository>(); mock.Setup(m => m.Products).Returns(new Product[] { new Product {ProductId = 1, ProductName = "P1", ProductCategoryId = 1}, new Product {ProductId = 4, ProductName = "P2", ProductCategoryId = 2}, }); // Arrange - create the controller NavController target = new NavController(mock.Object); // Arrange - define the category to selected int categoryToSelect = 1; // Action int result = target.Menu(categoryToSelect).ViewBag.SelectedCategory; // Assert Assert.AreEqual(categoryToSelect, result); }