public override void Compare(IComparison <CurveChartTemplate> comparison)
 {
     _objectComparer.Compare(comparison.ChildComparison(x => x.ChartSettings));
     _objectComparer.Compare(comparison.ChildComparison(x => x.FontAndSize));
     _enumerableComparer.CompareEnumerables(comparison, x => x.Axes, item => item.Caption);
     _enumerableComparer.CompareEnumerables(comparison, x => x.Curves, item => item.Name);
 }
        public override void Compare(IComparison <Simulation> comparison)
        {
            _lazyLoadTask.Load(comparison.Object1);
            _lazyLoadTask.Load(comparison.Object2);

            _comparer.Compare(comparison.ChildComparison(x => x.Model));
            _comparer.Compare(comparison.ChildComparison(x => x.UsedBuildingBlocks));
        }
 public override void Compare(IComparison <CurveTemplate> comparison)
 {
     CompareValues(x => x.Name, x => x.Name, comparison);
     _objectComparer.Compare(comparison.ChildComparison(x => x.xData));
     _objectComparer.Compare(comparison.ChildComparison(x => x.yData));
     CompareValues(x => x.IsBaseGrid, x => x.IsBaseGrid, comparison);
     _objectComparer.Compare(comparison.ChildComparison(x => x.CurveOptions));
 }
Exemple #4
0
 public override void Compare(IComparison <ISimulationSettings> comparison)
 {
     _objectBaseDiffBuilder.Compare(comparison);
     _objectComparer.Compare(comparison.ChildComparison(x => x.OutputSchema));
     _objectComparer.Compare(comparison.ChildComparison(x => x.Solver));
     _objectComparer.Compare(comparison.ChildComparison(x => x.OutputSelections));
     // not normal usage, but OutputSelections is only a enumeration at this point
     _enumerableComparer.CompareEnumerables(comparison, x => x.OutputSelections.AllOutputs, item => item.Path);
     _enumerableComparer.CompareEnumerables(comparison, x => x.ChartTemplates, item => item.Name);
 }
Exemple #5
0
 public override void Compare(IComparison <IMoBiBuildConfiguration> comparison)
 {
     _objectComparer.Compare(comparison.ChildComparison(x => x.SpatialStructureInfo, comparison.CommonAncestor));
     _objectComparer.Compare(comparison.ChildComparison(x => x.MoleculesInfo, comparison.CommonAncestor));
     _objectComparer.Compare(comparison.ChildComparison(x => x.ReactionsInfo, comparison.CommonAncestor));
     _objectComparer.Compare(comparison.ChildComparison(x => x.PassiveTransportsInfo, comparison.CommonAncestor));
     _objectComparer.Compare(comparison.ChildComparison(x => x.EventGroupsInfo, comparison.CommonAncestor));
     _objectComparer.Compare(comparison.ChildComparison(x => x.ObserversInfo, comparison.CommonAncestor));
     _objectComparer.Compare(comparison.ChildComparison(x => x.SimulationSettingsInfo, comparison.CommonAncestor));
     _objectComparer.Compare(comparison.ChildComparison(x => x.ParameterStartValuesInfo, comparison.CommonAncestor));
     _objectComparer.Compare(comparison.ChildComparison(x => x.MoleculeStartValuesInfo, comparison.CommonAncestor));
 }
        public override void Compare(IComparison <IParameter> comparison)
        {
            if (!ShouldCompareParametersIn(comparison))
            {
                return;
            }

            _quantityDiffBuilder.Compare(comparison);
            CompareValues(x => x.BuildMode, x => x.BuildMode, comparison);

            if (shouldCompareRHSFormula(comparison))
            {
                _objectComparer.Compare(comparison.ChildComparison(x => x.RHSFormula));
            }
            else
            {
                CompareValues(x => x.RHSFormula != null, Captions.Diff.IsStateVariable, comparison);
            }

            if (comparison.Settings.OnlyComputingRelevant)
            {
                return;
            }

            CompareValues(x => x.Visible, x => x.Visible, comparison);
        }
Exemple #7
0
 public override void Compare(IComparison <IEventAssignmentBuilder> comparison)
 {
     _entityDiffBuilder.Compare(comparison);
     CompareValues(x => x.UseAsValue, x => x.UseAsValue, comparison);
     CompareValues(x => x.Dimension, x => x.Dimension, comparison);
     _objectComparer.Compare(comparison.FormulaComparison());
 }
Exemple #8
0
 public override void Compare(IComparison <ITransport> comparison)
 {
     _containerDiffBuilder.Compare(comparison);
     CompareValues(x => _entityPathResolver.PathFor(x.TargetAmount), Captions.Diff.TargetAmount, comparison);
     CompareValues(x => _entityPathResolver.PathFor(x.SourceAmount), Captions.Diff.SourceAmount, comparison);
     _objectComparer.Compare(comparison.FormulaComparison());
 }
        public override void Compare(IComparison <IModel> comparison)
        {
            //Pass common ancestor here (simulation) so that message and type displayed to user reflects its expectations. (Model is only used internally)
            _objectComparer.Compare(comparison.ChildComparison(x => x.Root, comparison.CommonAncestor));

            //Neighborhood are defined as child container of the Model root container so no need to compare neighborhoods as well
        }
 public override void Compare(IComparison <IEventAssignment> comparison)
 {
     _entityDiffBuilder.Compare(comparison);
     CompareValues(x => x.UseAsValue, x => x.UseAsValue, comparison);
     _objectComparer.Compare(comparison.FormulaComparison());
     // Not Nessessary to compare Changed Object.
 }
 public override void Compare(IComparison <IReaction> comparison)
 {
     _containerDiffBuilder.Compare(comparison);
     _objectComparer.Compare(comparison.FormulaComparison());
     _enumerableComparer.CompareEnumerables(comparison, x => x.Educts, item => item.Partner.Name);
     _enumerableComparer.CompareEnumerables(comparison, x => x.Products, item => item.Partner.Name);
     _enumerableComparer.CompareEnumerables(comparison, x => x.ModifierNames, item => item, missingItemType: ObjectTypes.Modifier);
 }
Exemple #12
0
 public override void Compare(IComparison <IObserverBuilder> comparison)
 {
     _entityDiffBuilder.Compare(comparison);
     _moleculeDependentDiffBuilder.Compare(comparison);
     CompareValues(x => x.ContainerCriteria, x => x.ContainerCriteria, comparison);
     CompareValues(x => x.Dimension, x => x.Dimension, comparison);
     _objectComparer.Compare(comparison.FormulaComparison());
 }
Exemple #13
0
 public override void Compare(IComparison <IEvent> comparison)
 {
     _entityDiffBuilder.Compare(comparison);
     CompareValues(x => x.OneTime, x => x.OneTime, comparison);
     _objectComparer.Compare(comparison.FormulaComparison());
     _enumerableComparer.CompareEnumerables(comparison, x => x.Assignments, item => _entityPathResolver.ObjectPathFor(item.ChangedEntity));
     _enumerableComparer.CompareEnumerables(comparison, x => x.GetChildren <IEntity>(i => !i.IsAnImplementationOf <IEventAssignment>()), item => item.Name);
 }
Exemple #14
0
 public override void Compare(IComparison <ITransportBuilder> comparison)
 {
     _containerDiffBuilder.Compare(comparison);
     CompareValues(x => x.SourceCriteria, x => x.SourceCriteria, comparison);
     CompareValues(x => x.TargetCriteria, x => x.TargetCriteria, comparison);
     CompareValues(x => x.Dimension, x => x.Dimension, comparison);
     _moleculeDependentBuilderDiffBuilder.Compare(comparison);
     _objectComparer.Compare(comparison.FormulaComparison());
 }
 public override void Compare(IComparison <IReactionBuilder> comparison)
 {
     _containerDiffBuilder.Compare(comparison);
     _objectComparer.Compare(comparison.FormulaComparison());
     _enumerableComparer.CompareEnumerables(comparison, x => x.Educts, item => item.MoleculeName);
     _enumerableComparer.CompareEnumerables(comparison, x => x.Products, item => item.MoleculeName);
     _enumerableComparer.CompareEnumerables(comparison, x => x.ModifierNames, item => item, missingItemType: ObjectTypes.Modifier);
     CompareValues(x => x.ContainerCriteria, x => x.ContainerCriteria, comparison);
     CompareValues(x => x.Dimension, x => x.Dimension, comparison);
 }
        protected virtual void CompareStartValue(IComparison <T> comparison)
        {
            _entityDiffBuilder.Compare(comparison);
            CompareValues(x => x.Dimension, x => x.Dimension, comparison);
            CompareValues(x => x.ContainerPath, x => x.ContainerPath, comparison);

            // Always Compare Value and Formula, independent from settings as these are two different properties of a start value
            CompareNullableDoubleValues(x => x.StartValue, x => x.StartValue, comparison, x => x.DisplayUnit);
            _objectComparer.Compare(comparison.FormulaComparison());
        }
Exemple #17
0
        public bool Compare <T>(T first, T second)
            where T : class
        {
            if ((first == null && second != null) ||
                (first != null && second == null))
            {
                return(false);
            }
            else if (first != null && second != null)
            {
                PropertyInfo[] properties = first.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

                object propertyValueFirst, propertyValueSecond;
                Type   propertyType;
                foreach (PropertyInfo property in properties)
                {
                    if (property.CanRead)
                    {
                        propertyValueFirst  = property.GetValue(first, null);
                        propertyValueSecond = property.GetValue(second, null);

                        propertyType = property.PropertyType;

                        if (ReflectionGuard.IsPrimitiveType(propertyType))
                        {
                            if (!_primitiveComparer.Compare(propertyValueFirst, propertyValueSecond))
                            {
                                return(false);
                            }
                        }
                        else if (ReflectionGuard.IsEnumerableType(propertyType))
                        {
                            if (!_enumerationComparer.Compare(this, propertyValueFirst, propertyValueSecond))
                            {
                                return(false);
                            }
                        }
                        else if (ReflectionGuard.IsClass(propertyType))
                        {
                            if (!this.Compare(propertyValueFirst, propertyValueSecond))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Exemple #18
0
        public override void Compare(IComparison <IMoleculeBuilder> comparison)
        {
            _containerDiffBuilder.Compare(comparison);
            CompareValues(x => !x.IsFloating, Captions.Diff.Stationary, comparison);
            _enumerableComparerComparer.CompareEnumerables(comparison, x => x.UsedCalculationMethods, x => x.Category, missingItemType: ObjectTypes.CalculationMethod);
            _objectComparer.Compare(comparison.ChildComparison(x => x.DefaultStartFormula));
            if (comparison.Settings.OnlyComputingRelevant)
            {
                return;
            }

            CompareValues(x => x.QuantityType, x => x.QuantityType, comparison);
        }
Exemple #19
0
        public void StartComparison(IObjectBase leftObject, IObjectBase rightObject, string leftCaption, string rightCaption, ComparerSettings comparerSettings)
        {
            var diffReport = _objectComparer.Compare(leftObject, rightObject, comparerSettings);

            _view.LeftCaption  = leftCaption;
            _view.RightCaption = rightCaption;
            _allDiffItemDTO    = diffReport.Select(mapFrom).ToList();
            _view.BindTo(_allDiffItemDTO);
            EnumHelper.AllValuesFor <PathElement>().Each(updateColumnVisibility);

            //Always hide name
            _view.SetVisibility(PathElement.Name, visible: false);
            _view.DifferenceTableVisible = _allDiffItemDTO.Any();
        }
Exemple #20
0
        protected override void Context()
        {
            _view = A.Fake <IComparisonView>();
            _diffItemDTOMapper = A.Fake <IDiffItemToDiffItemDTOMapper>();
            _objectComparer    = A.Fake <IObjectComparer>();
            _dataTableMapper   = A.Fake <IDiffItemDTOsToDataTableMapper>();
            sut = new ComparisonPresenter(_view, _objectComparer, _diffItemDTOMapper, _dataTableMapper);

            _settings = new ComparerSettings();
            _object1  = A.Fake <IObjectBase>();
            _object2  = A.Fake <IObjectBase>();
            _report   = new DiffReport();

            A.CallTo(() => _objectComparer.Compare(_object1, _object2, _settings)).Returns(_report);
        }
        public bool Compare(IUserComparer userComparer, object first, object second)
        {
            if ((first == null && second != null) ||
                (first != null && second == null))
            {
                return(false);
            }
            else if (first != null && second != null)
            {
                IEnumerable <object> enumerableFirst, enumerableSecond;
                enumerableFirst  = ((IEnumerable)first).Cast <object>();
                enumerableSecond = ((IEnumerable)second).Cast <object>();


                if (enumerableFirst.Count() != enumerableSecond.Count())
                {
                    return(false);
                }
                else
                {
                    int count = enumerableFirst.Count();

                    object itemFirst, itemSecond;
                    Type   itemType;
                    for (int index = 0; index < count; index++)
                    {
                        itemFirst  = enumerableFirst.ElementAt(index);
                        itemSecond = enumerableSecond.ElementAt(index);
                        itemType   = itemFirst.GetType();

                        if (ReflectionGuard.IsPrimitiveType(itemType))
                        {
                            if (!_primitiveComparer.Compare(itemFirst, itemSecond))
                            {
                                return(false);
                            }
                        }
                        else if (!userComparer.Compare(itemFirst, itemSecond))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Exemple #22
0
        public int ComparePrimitive(object x, object y)
        {
            x = ReType(x);
            y = ReType(y);

            if (x.GetType() == y.GetType())
            {
                return((x as IComparable).CompareTo(y));
            }

            IObjectComparer cmp = comparers[string.Format("{0}:{1}", x.GetType(), y.GetType())] as IObjectComparer;

            if (cmp != null)
            {
                return(cmp.Compare(x, y));
            }

            throw new ArgumentException(string.Format("Unable to compare {0} and {1}", x.GetType(), y.GetType()));
        }
        public int ComparePrimitive(object x, object y)
        {
            x = ReType(x);
            y = ReType(y);

            if (x.GetType() == y.GetType())
            {
                return((x as IComparable).CompareTo(y));
            }

            IObjectComparer cmp = comparers[x.GetType() + ":" + y.GetType()] as IObjectComparer;

            if (cmp != null)
            {
                return(cmp.Compare(x, y));
            }

            throw new ArgumentException("Unable to compare " + x.GetType() + " and " + y.GetType());
        }
        public void CompareEnumerables <TParent, TItem>(IComparison <TParent> comparison,
                                                        Func <TParent, IEnumerable <TItem> > getEnumeration,
                                                        Func <TItem, TItem, bool> equalityFunc,
                                                        Func <TItem, string> identifierRetrieverFunc,
                                                        Func <TItem, string> presentObjectDetailsFunc = null,
                                                        string missingItemType = null)
            where TParent : class
            where TItem : class
        {
            var object1 = comparison.Object1;
            var object2 = comparison.Object2;
            var list1   = getEnumeration(object1).ToList();
            var list2   = getEnumeration(object2).ToList();

            foreach (var entity1 in list1)
            {
                var entity2 = list2.FirstOrDefault(item => equalityFunc(item, entity1));
                if (entity2 != null)
                {
                    var childComparison = new Comparison <TItem>(entity1, entity2, comparison.Settings, comparison.Report, object1);
                    _objectComparer.Compare(childComparison);
                }
                else
                {
                    var missingObjectType    = missingItemType ?? _objectTypeResolver.TypeFor(entity1);
                    var presentObjectDetails = presentObjectDetailsFunc?.Invoke(entity1) ?? string.Empty;
                    comparison.Add(missingItem(object1, object2, entity1, null, missingObjectType, identifierRetrieverFunc(entity1), presentObjectDetails));
                }
            }

            //all common entity have been added. Add missing entity from object1 base on object2
            foreach (var entity2 in list2)
            {
                if (list1.Any(item => equalityFunc(item, entity2)))
                {
                    continue;
                }

                var missingObjectType    = missingItemType ?? _objectTypeResolver.TypeFor(entity2);
                var presentObjectDetails = presentObjectDetailsFunc?.Invoke(entity2) ?? string.Empty;
                comparison.Add(missingItem(object1, object2, null, entity2, missingObjectType, identifierRetrieverFunc(entity2), presentObjectDetails));
            }
        }
        private void compareQuantities(IComparison <IQuantity> comparison)
        {
            _entityDiffBuilder.Compare(comparison);
            CompareValues(x => x.Dimension, x => x.Dimension, comparison);
            CompareValues(x => x.QuantityType, x => x.QuantityType, comparison);
            CompareValues(x => x.NegativeValuesAllowed, x => x.NegativeValuesAllowed, comparison);

            if (!comparison.Settings.OnlyComputingRelevant)
            {
                CompareValues(x => x.Persistable, x => x.Persistable, comparison);
                CompareValues(x => x.DisplayUnit, Captions.DisplayUnit, comparison);
            }

            if (shouldCompareValues(comparison))
            {
                CompareDoubleValues(x => x.Value, x => x.Value, comparison, x => x.DisplayUnit);
            }
            else
            {
                _objectComparer.Compare(comparison.FormulaComparison());
            }
        }
 public override void Compare(IComparison <ChartFontAndSizeSettings> comparison)
 {
     CompareValues(x => x.ChartHeight, x => x.ChartHeight, comparison);
     CompareValues(x => x.ChartWidth, x => x.ChartWidth, comparison);
     _objectComparer.Compare(comparison.ChildComparison(x => x.Fonts, comparison.CommonAncestor));
 }
Exemple #27
0
 public override void Compare(IComparison <ExpressionProfile> comparison)
 {
     CompareValues(x => x.Category, PKSimConstants.UI.ExpressionProfileCategory, comparison);
     //Species not required since it will be compared with the underlying individual
     _comparer.Compare(comparison.ChildComparison(x => x.Individual));
 }
Exemple #28
0
 public override void Compare(IComparison <Individual> comparison)
 {
     _comparer.Compare(comparison.ChildComparison(x => x.OriginData));
     _containerDiffBuilder.Compare(comparison);
 }
 public override void Compare(IComparison <IMoBiSimulation> comparison)
 {
     _objectComparer.Compare(comparison.ChildComparison(x => x.Model));
     _objectComparer.Compare(comparison.ChildComparison(x => x.MoBiBuildConfiguration));
 }
Exemple #30
0
 public override void Compare(IComparison <Individual> comparison)
 {
     _comparer.Compare(comparison.ChildComparison(x => x.OriginData));
     _enumerableComparer.CompareEnumerables(comparison, x => x.AllExpressionProfiles().AllNames(), x => x, missingItemType: PKSimConstants.ObjectTypes.ExpressionProfile);
     _containerDiffBuilder.Compare(comparison);
 }