コード例 #1
0
        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;
            }
        }
コード例 #2
0
        public void GivenAValueButNoType_Validate_ShouldHaveValidationErrors()
        {
            // Arrange.
            var unitOfMeasure = new UnitOfMeasure
            {
                Value = 1
            };

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

            // Act & Assert.
            _unitOfMeasureValidator.ShouldNotHaveValidationErrorFor(unit => unit.Value, unitOfMeasure);
        }
コード例 #4
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;
            }
        }
コード例 #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;
            }
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
        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;
        }