Пример #1
0
        public void Can_Create_Categories()
        {
            // Arrange
            // - create the mock repository
            Mock<IEmployeeRepository> mock = new Mock<IEmployeeRepository>();
            mock.Setup(m => m.Employees).Returns(new Employee[]
            {
                new Employee {EmployeeId = 1, Name = "Employee1", Status = "Active"},
                new Employee {EmployeeId = 2, Name = "Employee2", Status = "Active"},
                new Employee {EmployeeId = 3, Name = "Employee3", Status = "Inactive"},
                new Employee {EmployeeId = 4, Name = "Employee4", Status = "Inactive"},
            }.AsQueryable());

            // Arrange - create the controller
            NaviController target = new NaviController(mock.Object);

            // Act = get the set of categories
            string[] results = ((IEnumerable<string>)target.Menu().Model).ToArray();

            // Assert
            Assert.AreEqual(results.Length, 2);
            Assert.AreEqual(results[0], "Active");
            Assert.AreEqual(results[1], "Inactive");
        }
Пример #2
0
        public void Indicates_Selected_Position()
        {
            Mock<IEmployeeRepository> mock = new Mock<IEmployeeRepository>();
            mock.Setup(m => m.Employees).Returns(new Employee[]
            {
                new Employee {EmployeeId = 1, Name = "Employee1", Status = "Active"},
                new Employee {EmployeeId = 4, Name = "Employee2", Status = "Inactive"},
            }.AsQueryable);

            NaviController target = new NaviController(mock.Object);

            string categoryToSelect = "Active";

            string result = target.Menu(categoryToSelect).ViewBag.SelectedCategory;

            Assert.AreEqual(categoryToSelect, result);
        }