Exemplo n.º 1
0
        public void ValidateOperators()
        {
            if (!IsRange)
            {
                return;
            }

            var operators = (LowerBoundOperator, UpperBoundOperator);

            switch (operators)
            {
            case ("<", "<"):
            case ("<", "<="):
            case ("<=", "<"):
            case ("<=", "<="):
            case (">", ">"):
            case (">=", ">"):
            case (">", ">="):
            case (">=", ">="): return;

            default:
                DomainExceptionCode.Throw(DomainError.D033, this);
                break;
            }
        }
Exemplo n.º 2
0
        public void ReplaceThresholds(List <Threshold> thresholds)
        {
            var listMetricStatusIds = thresholds.Select(t => t.MetricStatusId).ToList();
            var listDistinctIds     = listMetricStatusIds.Distinct().ToList();

            if (!listDistinctIds.SequenceEqual(listMetricStatusIds))
            {
                DomainExceptionCode.Throw(DomainError.D023, this, Thresholds);
            }

            if (thresholds.Any(t => t.MetricId > 0 && t.MetricId != Id))
            {
                DomainExceptionCode.Throw(DomainError.D022, this, thresholds);
            }

            var listRemove = Thresholds.Except(thresholds, Threshold.ThresholdComparer).ToList();
            var listAddNew = thresholds.Except(Thresholds, Threshold.ThresholdComparer).ToList();
            var listUpdate = thresholds.Intersect(Thresholds, Threshold.ThresholdComparer).ToList();

            listRemove.ForEach(i => _thresholds.Remove(i));

            listAddNew.ForEach(i => _thresholds.Add(i));

            listUpdate.ForEach(i =>
            {
                var item = Thresholds.First(t => t.MetricId == i.MetricId && t.MetricStatusId == i.MetricStatusId);
                item.UpdateValue(item.MetricStatusId, item.MetricId, i.UpperBound, i.LowerBound, i.UpperBoundOperator,
                                 i.LowerBoundOperator, i.IsRange, i.Value);
            });

            ValidateThresholds();
            ThresholdMustHaveDifferentMetricStatus();
        }
Exemplo n.º 3
0
 public void ValueTypeIsSelect_SelectValueMustHaveValue()
 {
     if (ValueType == DoDHelper.ValueTypeSelect && string.IsNullOrEmpty(SelectValues))
     {
         DomainExceptionCode.Throw(DomainError.D029, this);
     }
 }
Exemplo n.º 4
0
        public void ValueTypeMustBeValid()
        {
            var validValueTypes = new[]
            { DoDHelper.ValueTypeText, DoDHelper.ValueTypeNumber, DoDHelper.ValueTypeSelect };

            if (!validValueTypes.Contains(ValueType))
            {
                DomainExceptionCode.Throw(DomainError.D024, this);
            }
        }
Exemplo n.º 5
0
        public void ValidateThresholds()
        {
            if (Thresholds.Count() > 3)
            {
                DomainExceptionCode.Throw(DomainError.D025, this, Thresholds);
            }

            foreach (var threshold in Thresholds)
            {
                switch (ValueType, threshold.IsRange)
                {
Exemplo n.º 6
0
        public void ValidateIsRange()
        {
            if (IsRange)
            {
                if (!string.IsNullOrEmpty(Value))
                {
                    DomainExceptionCode.Throw(DomainError.D030, this, Metric);
                }

                if (LowerBound == null || UpperBound == null ||
                    LowerBoundOperator == null || UpperBoundOperator == null)
                {
                    DomainExceptionCode.Throw(DomainError.D032, this, Metric);
                }
            }
        }
        public void AddEditQualityReport(QualityReport item)
        {
            // TODO Validate Quality Report data
            if (item.ReOpenBugs > item.CriticalBugs + item.MajorBugs + item.MinorBugs)
            {
                DomainExceptionCode.Throw(DomainError.D039, this);
            }

            if (item.Id == 0)
            {
                _qualityReports.Add(item);
            }
            else
            {
                var itemInDb = _qualityReports.First(b => b.Id == item.Id);
                itemInDb.UpdateValue(item);
            }

            this.ValidateQualityReport();
        }
Exemplo n.º 8
0
 public DomainException(DomainExceptionCode code)
     : base(code.ToString())
 {
     Code = code;
 }