Exemplo n.º 1
0
        private void AssertStateEntityNameResolution(StateType stateType, string entityName, string expectedResolvedEntityName)
        {
            var entity             = GetPropertyInfoByName(stateType, entityName);
            var resolvedEntityName = new StateEntityNameResolver().Resolve(entity);

            Assert.AreEqual(expectedResolvedEntityName, resolvedEntityName, string.Format(FAILED_ENTITY_NAME_RESOLVING, resolvedEntityName));
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method travels all the fields of ItemType comparing with the fields of another itemType.
        /// </summary>
        /// <param name="typeOfItemType">Type of the type of item.</param>
        /// <param name="typeOfStateType">Type of the type of other item.</param>
        /// <returns></returns>
        public bool IsEquals()
        {
            var  stateEntityNameResolver = new StateEntityNameResolver();
            Type typeOfItemType          = itemType.GetType();
            Type typeOfStateType         = stateType.GetType();

            var fiedsOfStateType = typeOfStateType.GetProperties();


            foreach (var field in fiedsOfStateType)
            {
                var valueOfState    = field.GetValue(this.stateType, null);
                var stateEntityName = stateEntityNameResolver.Resolve(field);

                if (valueOfState is EntitySimpleBaseType)
                {
                    if ((EntitySimpleBaseType)valueOfState != null)
                    {
                        var allItemEntities = typeOfItemType.GetProperties();
                        var fieldOfItemType =
                            allItemEntities
                            .FirstOrDefault(x => x.Name.Equals(stateEntityName, StringComparison.InvariantCultureIgnoreCase));
                        if (fieldOfItemType == null)
                        {
                            return(false);
                        }

                        if (!this.ProcessComparations(field, fieldOfItemType))
                        {
                            return(false);
                        }
                    }
                }
                else if (valueOfState is EntityComplexBaseType)
                {
                    if ((EntityComplexBaseType)valueOfState != null)
                    {
                        var fieldOfItemType =
                            typeOfItemType.GetProperties()
                            .FirstOrDefault(x => x.Name.Equals(field.Name, StringComparison.InvariantCultureIgnoreCase));

                        if (fieldOfItemType == null)
                        {
                            return(false);
                        }
                        else
                        {
                            return(ProcessComparisionForComplexEntityType(
                                       (EntityItemRecordType[])fieldOfItemType.GetValue(this.itemType, null),
                                       (EntityStateRecordType)valueOfState));
                        }
                    }
                }
            }
            return(true);
        }