Esempio n. 1
0
        protected override MutableObject Mutate(MutableObject mutable)
        {
            var groupId = GroupId.GetFirstValue(mutable);

            if (groupId == "")
            {
                DataShare.Remove(groupId);
            }

            foreach (var entry in DiffValue.GetEntries(mutable))
            {
                if (DataShare.ContainsKey(groupId))
                {
                    DiffTarget.SetValue(
                        DiffValue.GetValue(entry) - DataShare[groupId], entry);
                    DataShare[groupId] = DiffValue.GetValue(entry);
                }
                else
                {
                    DiffTarget.SetValue(0f, entry);
                    DataShare[groupId] = DiffValue.GetValue(entry);
                }
            }

            return(mutable);
        }
Esempio n. 2
0
        public void ToString_ReturnStringRepresentation()
        {
            var    diffVal  = new DiffValue(DiffAction.Added, Raw);
            string result   = diffVal.ToString();
            string expected = "+ Value: \"theValue\"\r\n";

            Assert.AreEqual(expected, result);
        }
Esempio n. 3
0
        public void Visit(DiffValue val, int param)
        {
            string indent = string.Empty;

            if (!_closeLineWithoutPrefixMode)
            {
                DrawLineBreak();
                indent = BuildIndent(param);
                _closeLineWithoutPrefixMode = true;
            }
            _sb.AppendFormat("{0}<span{1}>{2}</span>", indent, ActionToString(val.Action), System.Security.SecurityElement.Escape(val.Raw));
        }
Esempio n. 4
0
        private void Calculate()
        {
            if (DiffValueTextBlock == null)
            {
                return;
            }
            DiffValueStatus = DataB > DataA ? CompareValueType.Up : DataB < DataA ? CompareValueType.Down : CompareValueType.NoChange;

            double c = DataB - DataA;

            if (c != 0)
            {
                DiffValue = Math.Round(c / DataA * 100, 1);
                if (DataA == 0)
                {
                    DiffValue = 100;
                }
            }

            switch (DiffValueStatus)
            {
            case CompareValueType.Up:
                DiffValueTextBlock.Foreground = UPColor;
                break;

            case CompareValueType.Down:
                DiffValueTextBlock.Foreground = DownColor;
                break;

            case CompareValueType.NoChange:
                DiffValueTextBlock.Foreground = NoChangeColor;
                break;
            }
            string popupText = PopupText;

            popupText = popupText.Replace("{a}", $"{DataA.ToString()}");
            popupText = popupText.Replace("{b}", $"{DataB.ToString()}");

            string diffvalueText = DiffValue > 0 ? $"+{DiffValue.ToString()}%" : DiffValue == 0 ? $"{Application.Current.Resources["Lang_Nochange"]}" : $"{DiffValue.ToString()}%";

            if (DataA == DataB)
            {
                diffvalueText = $"{Application.Current.Resources["Lang_Nochange"]}";
            }
            popupText           = popupText.Replace("{diffvalue}", diffvalueText);
            PopupTextBlock.Text = popupText;
        }
Esempio n. 5
0
 public void Visit(DiffValue val, XdtContext param)
 {
     param.XElement.SetValue(val.Raw);
     param.ValueChanged = true;
 }
Esempio n. 6
0
        public void Visit(DiffValue val, int level)
        {
            string indent = BuildIndent(level);

            _sb.AppendFormat("{0}{1} Value: \"{2}\"\r\n", indent, ActionToString(val.Action), val.Raw);
        }
Esempio n. 7
0
        public void IsChangedProperty_ShouldAlwaysBeTrue(DiffAction action)
        {
            var diffVal = new DiffValue(action, Raw);

            Assert.IsTrue(diffVal.IsChanged);
        }