예제 #1
0
        public void Index_Contains_All_Rules()
        {
            // Arrange - create the mock repository
            Mock <IRuleRepository> mock = new Mock <IRuleRepository>();

            mock.Setup(m => m.LoadRules).Returns(new MT_LOAD_RULE[] {
                new MT_LOAD_RULE {
                    LoadRuleId = 1, Code = "LR1"
                },
                new MT_LOAD_RULE {
                    LoadRuleId = 2, Code = "LR2"
                },
                new MT_LOAD_RULE {
                    LoadRuleId = 3, Code = "LR3"
                },
            }.AsQueryable());
            // Arrange - create a controller
            RuleController target = new RuleController(mock.Object);

            // Action
            MT_LOAD_RULE[] result = ((IEnumerable <MT_LOAD_RULE>)target.Rules().ViewData.Model).ToArray();
            // Assert
            Assert.AreEqual(result.Length, 3);
            Assert.AreEqual("LR1", result[0].Code);
            Assert.AreEqual("LR2", result[1].Code);
            Assert.AreEqual("LR3", result[2].Code);
        }