public void Copy(BuildingDetails newBuildingDetails)
        {
            if (newBuildingDetails == null)
            {
                throw new ArgumentNullException("newBuildingDetails");
            }

            if (newBuildingDetails.IsAreaModified)
            {
                if (newBuildingDetails.Area == null)
                {
                    Area = null;
                }
                else
                {
                    if (Area== null)
                    {
                        Area = new UnitOfMeasure();
                    }

                    if (newBuildingDetails.Area.IsModified)
                    {
                        Area = newBuildingDetails.Area;
                    }

                    IsAreaModified = true;
                }
            }

            if (newBuildingDetails.IsEnergyRatingModified)
            {
                EnergyRating = newBuildingDetails.EnergyRating;
            }
        }
        public void GivenAValueButNoType_Validate_ShouldHaveValidationErrors()
        {
            // Arrange.
            var unitOfMeasure = new UnitOfMeasure
            {
                Value = 1
            };

            // Act & Assert.
            _unitOfMeasureValidator.ShouldHaveValidationErrorFor(unit => unit.Type, unitOfMeasure);
        }
        public void GivenAValueAndAType_Validate_ShouldNotHaveValidationErrors()
        {
            // Arrange.
            var unitOfMeasure = new UnitOfMeasure
            {
                Type = "a",
                Value = 1
            };

            // Act & Assert.
            _unitOfMeasureValidator.ShouldNotHaveValidationErrorFor(unit => unit.Value, unitOfMeasure);
        }
        public void Copy(UnitOfMeasure newUnitOfMeasure)
        {
            if (newUnitOfMeasure == null)
            {
                throw new ArgumentNullException("newUnitOfMeasure");
            }

            if (newUnitOfMeasure.IsTypeModified)
            {
                Type = newUnitOfMeasure.Type;
            }

            if (newUnitOfMeasure.IsValueModified)
            {
                Value = newUnitOfMeasure.Value;
            }
        }
Пример #5
0
        public void Copy(UnitOfMeasure newUnitOfMeasure)
        {
            if (newUnitOfMeasure == null)
            {
                throw new ArgumentNullException("newUnitOfMeasure");
            }

            if (newUnitOfMeasure.IsTypeModified)
            {
                Type = newUnitOfMeasure.Type;
            }

            if (newUnitOfMeasure.IsValueModified)
            {
                Value = newUnitOfMeasure.Value;
            }
        }
        public void Copy(LandDetails newLandDetails)
        {
            if (newLandDetails == null)
            {
                throw new ArgumentNullException("newLandDetails");
            }

            if (newLandDetails.IsAreaModified)
            {
                if (newLandDetails.Area == null)
                {
                    Area = null;
                }
                else
                {
                    if (Area == null)
                    {
                        Area = new UnitOfMeasure();
                    }
                    Area.Copy(newLandDetails.Area);
                }
            }

            if (newLandDetails.IsFrontageModified)
            {
                if (newLandDetails.Frontage == null)
                {
                    Frontage = null;
                }
                else
                {
                    if (Frontage == null)
                    {
                        Frontage = new UnitOfMeasure();
                    }
                    Frontage = newLandDetails.Frontage;
                }
            }

            if (newLandDetails.IsDepthsModified)
            {
                Depths = newLandDetails.Depths;
            }

            if (newLandDetails.IsCrossOverModified)
            {
                CrossOver = newLandDetails.CrossOver;
            }
        }
        public static UnitOfMeasure UnitOfMeasureOrDefault(this XElement xElement, string elementName, string attributeName)
        {
            var value = xElement.DecimalValueOrDefault(elementName);

            UnitOfMeasure unitOfMeasure = null;
            var type = xElement.ValueOrDefault(elementName, attributeName);

            if (value > 0)
            {
                unitOfMeasure = new UnitOfMeasure
                {
                    Value = value,
                    Type = string.IsNullOrWhiteSpace(type)
                        ? "Total"
                        : type
                };
            }

            return unitOfMeasure;
        }