Ejemplo n.º 1
0
        public void Can_Delete_Valid_Rules()
        {
            // Arrange - create a Product
            MT_LOAD_RULE loadRule = new MT_LOAD_RULE {
                LoadRuleId = 2, Code = "Test"
            };
            // 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"
                },
                loadRule,
                new MT_LOAD_RULE {
                    LoadRuleId = 3, Code = "LR3"
                },
            }.AsQueryable());
            // Arrange - create the controller
            RuleController target = new RuleController(mock.Object);

            // Act - delete the product
            target.RuleDelete(loadRule.LoadRuleId);
            // Assert - ensure that the repository delete method was
            // called with the correct Product
            mock.Verify(m => m.DeleteLoadRule(loadRule.LoadRuleId));
        }