Exemple #1
0
        public void ActivateCriterion(Criterion criterion)
        {
            if (MethodVMByIdDict == null)
                return;
            ActiveCriterion = criterion;
            foreach (var kvp in MethodVMByIdDict)
            {
                uint methodId = kvp.Key;
                MethodViewModel methodViewModel = kvp.Value;

                Method method = MethodModelByIdDict[methodId];
                Contract.Assume(method.Id == methodViewModel.Id);
                IValue activeValue = method.GetValueFor(criterion);
                IValue maxValue = CriteriaContext.GetMaxValueFor(criterion);

                methodViewModel.Opacity = activeValue.ConvertToZeroOneScale(maxValue) * 0.8 + 0.1;
                methodViewModel.ActiveValue = activeValue;

            }

            var newSortedMethodVMs = SortedMethodVMs.OrderByDescending(mvm => mvm.ActiveValue).ToArray();
            SortedMethodVMs.Clear();
            foreach (var methodVM in newSortedMethodVMs)
            {
                SortedMethodVMs.Add(methodVM);
            }
        }
 public CriterionSwitchViewModel(Criterion criterion)
 {
     _criterion = criterion;
     _command = new RelayCommand(o =>{
                                         Action<Criterion> handler = CriterionChanged;
                                         if (handler != null)handler(_criterion);});
 }
 public void InequalityTest()
 {
     Criterion criterion1 = new Criterion("this is a random text");
     Criterion criterion2 = new Criterion("this also");
     Assert.IsTrue(criterion1 != criterion2);
     Assert.IsFalse(criterion1.Equals((object)criterion2));
     Assert.IsFalse(criterion1.Equals(criterion2));
 }
        public IValue GetMaxValueFor(Criterion criterion)
        {
            if (criterion == TopStackOccurrenceCriterion)
                return _maxTopStackOccurrence;

            if (criterion == DurationCriterion)
                return _maxDuration;

            var exceptionMessage = string.Format("Criterion of type {0} is not available in {1}", criterion.GetType().Name,
                                                 this.GetType().Name);
            throw new ArgumentException(exceptionMessage);
        }
        public override IValue GetValueFor(Criterion criterion)
        {
            if (criterion == SamplingCriteriaContext.TopStackOccurrenceCriterion)
                return _topStackOccurrence;

            if (criterion == SamplingCriteriaContext.DurationCriterion)
                return _duration;

            string message = string.Format("Criterion {0} is not supported for a tracing method",
                                           criterion.GetType().Name);
            throw new ArgumentException(message);
        }
        public IValue GetMaxValueFor(Criterion criterion)
        {
            if (criterion == CallCountCriterion)
                return _maxCallCount;
            if (criterion == TimeWallClockCriterion)
                return _maxTimeWallClock;
            if (criterion == TimeActiveCriterion)
                return _maxTimeActive;

            var exceptionMessage = string.Format("Criterion of type {0} is not available in {1}", criterion.GetType().Name,
                                                 this.GetType().Name);
            throw new ArgumentException(exceptionMessage);
        }
        public override IValue GetValueFor(Criterion criterion)
        {
            if (criterion == TracingCriteriaContext.CallCountCriterion)
                return _callCountValue;

            if (criterion == TracingCriteriaContext.TimeWallClockCriterion)
                return _timeWallClockValue;

            if (criterion == TracingCriteriaContext.TimeActiveCriterion)
                return _timeActiveValue;

            string message = string.Format("Criterion {0} is not supported for a tracing method", criterion.GetType().Name);
            throw new ArgumentException(message);
        }
        public void SetUp()
        {
            Criterion criterion01 = new Criterion("criterion01");
            Criterion criterion02 = new Criterion("criterion02");
            Mock<ICriteriaContext> mock = new Mock<ICriteriaContext>(MockBehavior.Strict);
            mock.SetupGet(cc => cc.AvailableCriteria).Returns(new[]
                                                                  {
                                                                     criterion01,
                                                                     criterion02
                                                                  });
            mock.Setup(cc => cc.GetMaxValueFor(criterion01)).Returns(new UintValue(50));
            mock.Setup(cc => cc.GetMaxValueFor(criterion02)).Returns(new UintValue(60));

            var availableCriteria = mock.Object.AvailableCriteria;
            var maxValueFor = mock.Object.GetMaxValueFor(criterion01);

              //  ContainingUnit containingUnit = new ContainingUnit();
        }
Exemple #9
0
 public abstract IValue GetValueFor(Criterion criterion);