public void AddRule(RuleDto ruleDto)
        {
            var rule = new Rule
            {
                vchName = ruleDto.Name,
                bEnabled = ruleDto.Enabled,
                vchAction = ruleDto.Action,
                tPoolActiveTime = ruleDto.PoolActiveTime,
                iPoolMaxMessages = ruleDto.PoolMaxMessages,
                iOrder = ruleDto.Order,
                vchCustomSubject = ruleDto.CustomSubject ?? "",
                vchApplicationName = ruleDto.ApplicationName ?? "",
                vchMachineName = ruleDto.MachineName ?? "",
                vchHelpText = ruleDto.HelpText ?? "",
                vchCommandLineArgs = ruleDto.CommandLineArgs ?? "",
                vchStackTrace = ruleDto.StackTrace ?? "",
                vchExceptionType = ruleDto.ExceptionType ?? "",
                vchExceptionMessage = ruleDto.ExceptionMessage ?? "",
                iApplicationGroupID = ruleDto.ApplicationGroupId != 0 ? ruleDto.ApplicationGroupId : null,
                iMachineGroupID = ruleDto.MachineGroupId != 0 ? ruleDto.MachineGroupId : null,
                iPriorityID = ruleDto.PriorityId != 0 ? ruleDto.PriorityId : null,
                bContinueProcessing = ruleDto.ContinueProcessing
            };

            Uow.Rules.Add(rule);
            Uow.Commit();
        }
        public void DeleteRuleById_DeletesRuleAndUpdatesOrder()
        {
            // arrange
            var ruleToDelete = new Rule
            {
                iRuleID = 1,
                iOrder = 1
            };

            var rules = new List<Rule>
            {
                new Rule {iRuleID = 2, iOrder = 2},
                new Rule {iRuleID = 3, iOrder = 3}
            };

            MockRepoRule.Setup(x => x.GetById(1)).Returns(ruleToDelete);
            MockRepoRule.Setup(x => x.GetRulesAfterOrderNumber(1)).Returns(rules);

            // act
            RuleService.DeleteRuleById(1);

            // assert
            Assert.AreEqual(1, rules[0].iOrder);
            Assert.AreEqual(2, rules[1].iOrder);
            rules.ForEach(rule => MockRepoRule.Verify(x => x.Update(rule)));
            MockRepoRule.Verify(x => x.Delete(1));
            MockUow.Verify(x => x.Commit());
        }
        public void Initialize()
        {
            _scope = new TransactionScope();

            _rule = new Rule();
            _uow.Rules.Add(_rule);
            _uow.Commit();

            _pool = new Pool {iRuleID = _rule.iRuleID, dtStartTime = DateTime.Now};
            _uow.Pools.Add(_pool);
            _uow.Commit();

            _message = new Message();
            _uow.Messages.Add(_message);
            _uow.Commit();
        }
        public void UpdateRule()
        {
            // arrange
            var ruleDto = new RuleDto()
            {
                Id = 1,
                Order = 4
            };

            var rule = new Rule()
            {
                iRuleID = 1,
                iOrder = 2
            };

            MockRepoRule.Setup(x => x.GetById(ruleDto.Id)).Returns(rule);

            // act
            RuleService.UpdateRule(ruleDto);

            // assert
            MockRepoRule.Verify(x => x.Update(rule));
            MockUow.Verify(x => x.Commit());
        }