예제 #1
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;
            }
        }
        public void GivenAnAreaWithNoType_Validate_ShouldHaveAValidationError()
        {
            // Arrange.
            var validator = new LandDetailsValidator();
            var landDetails = new LandDetails
            {
                Area = new UnitOfMeasure
                {
                    Type = null,
                    Value = 1m
                }
            };

            // Act.
            validator.ShouldHaveChildValidator(land => land.Area, typeof (UnitOfMeasureValidator));
            var result = validator.Validate(landDetails);
            //validator.ShouldHaveValidationErrorFor(land => land.Area, area);

            // Assert.
            result.Errors.ShouldContain(x => x.PropertyName == "Area.Type");
        }
        public void GivenAnArea_Validate_ShouldNotHaveAValidationError()
        {
            // Arrange.
            var validator = new LandDetailsValidator();
            var landDetails = new LandDetails
            {
                Area = new UnitOfMeasure
                {
                    Type = "a",
                    Value = 1m
                }
            };

            // Act.
            validator.ShouldHaveChildValidator(land => land.Area, typeof (UnitOfMeasureValidator));
            var result = validator.Validate(landDetails);
            //validator.ShouldHaveValidationErrorFor(land => land.Area, area);

            // Assert.
            result.Errors.Count.ShouldBe(0);
        }
예제 #4
0
        public void Copy(Listing newListing)
        {
            if (newListing == null)
            {
                throw new ArgumentNullException("newListing");
            }

            if (!newListing.IsModified)
            {
                return;
            }

            base.Copy(newListing);

            if (newListing.IsAgencyIdModified)
            {
                AgencyId = newListing.AgencyId;
            }

            if (newListing.IsStatusTypeModified)
            {
                StatusType = newListing.StatusType;
            }

            if (newListing.IsCreatedOnModified)
            {
                CreatedOn = newListing.CreatedOn;
            }

            if (newListing.IsTitleModified)
            {
                Title = newListing.Title;
            }

            if (newListing.IsDescriptionModified)
            {
                Description = newListing.Description;
            }

            if (newListing.IsAddressModified)
            {
                if (newListing.Address == null)
                {
                    Address = null;
                }
                else
                {
                    if (Address == null)
                    {
                        Address = new Address();
                    }

                    if (newListing.Address.IsModified)
                    {
                        Address.Copy(newListing.Address);
                    }

                    IsAddressModified = true;
                }
            }

            if (newListing.IsAgentsModified)
            {
                if (newListing.Agents == null)
                {
                    Agents = null;
                }
                else
                {
                    Agents = new List<ListingAgent>();
                    foreach (var newAgent in newListing.Agents)
                    {
                        var agent = new ListingAgent();
                        agent.Copy(newAgent);
                        Agents.Add(agent);
                    }
                }
            }

            if (newListing.IsImagesModified)
            {
                if (newListing.Images == null)
                {
                    Images = null;
                }
                else
                {
                    Images = new List<Media>();
                    foreach (var newImage in newListing.Images)
                    {
                        var image = new Media();
                        image.Copy(newImage);
                        Images.Add(image);
                    }
                }
            }

            if (newListing.IsFloorPlansModified)
            {
                if (newListing.FloorPlans == null)
                {
                    FloorPlans = null;
                }
                else
                {
                    FloorPlans = new List<Media>();
                    foreach (var newFloorPlan in newListing.FloorPlans)
                    {
                        var floorPlan = new Media();
                        floorPlan.Copy(newFloorPlan);
                        FloorPlans.Add(floorPlan);
                    }
                }
            }

            if (newListing.IsVideosModified)
            {
                if (newListing.Videos == null)
                {
                    Videos = null;
                }
                else
                {
                    Videos = new List<Media>();
                    foreach (var newVideo in newListing.Videos)
                    {
                        var video = new Media();
                        video.Copy(newVideo);
                        Videos.Add(video);
                    }
                }
            }

            if (newListing.IsInspectionsModified)
            {
                if (newListing.Inspections == null)
                {
                    Inspections = null;
                }

                else
                {
                    Inspections = new List<Inspection>();
                    foreach (var newInspection in newListing.Inspections)
                    {
                        var inspection = new Inspection();
                        inspection.Copy(newInspection);
                        Inspections.Add(inspection);
                    }

                }
            }

            if (newListing.IsLandDetailsModified)
            {
                if (newListing.LandDetails == null)
                {
                    LandDetails = null;
                }
                else
                {
                    if (LandDetails == null)
                    {
                        LandDetails = new LandDetails();
                    }

                    if (newListing.LandDetails.IsModified)
                    {
                        LandDetails.Copy(newListing.LandDetails);
                    }

                    IsLandDetailsModified = true;
                }
            }

            if (newListing.IsFeaturesModified)
            {
                if (newListing.Features == null)
                {
                    Features = null;
                }
                else
                {
                    if (Features == null)
                    {
                        Features = new Features();
                    }

                    if (newListing.Features.IsModified)
                    {
                        Features.Copy(newListing.Features);
                    }

                    IsFeaturesModified = true;
                }
            }

            if (newListing.IsLinksModified)
            {
                Links = newListing.Links == null
                    ? null
                    : new List<string>(newListing.Links);
            }
        }
        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;
            }
        }
 private static void AssertLandDetails(LandDetails landDetails,
     bool isModified)
 {
     landDetails.Area.Value.ShouldBe(80M);
     landDetails.Area.IsValueModified.ShouldBe(isModified);
     landDetails.Area.Type.ShouldBe("square");
     landDetails.Area.IsTypeModified.ShouldBe(isModified);
     landDetails.Frontage.Value.ShouldBe(20M);
     landDetails.Frontage.IsValueModified.ShouldBe(isModified);
     landDetails.Frontage.Type.ShouldBe("meter");
     landDetails.Frontage.IsTypeModified.ShouldBe(isModified);
     landDetails.Depths[0].Value.ShouldBe(40M);
     landDetails.Depths[0].IsValueModified.ShouldBe(isModified);
     landDetails.Depths[0].Type.ShouldBe("meter");
     landDetails.Depths[0].IsTypeModified.ShouldBe(isModified);
     landDetails.Depths[0].Side.ShouldBe("rear");
     landDetails.Depths[0].IsSideModified.ShouldBe(isModified);
     landDetails.Depths[1].Value.ShouldBe(60M);
     landDetails.Depths[1].IsValueModified.ShouldBe(isModified);
     landDetails.Depths[1].Type.ShouldBe("meter");
     landDetails.Depths[1].IsTypeModified.ShouldBe(isModified);
     landDetails.Depths[1].Side.ShouldBe("left");
     landDetails.Depths[1].IsSideModified.ShouldBe(isModified);
     landDetails.Depths[2].Value.ShouldBe(20M);
     landDetails.Depths[2].IsValueModified.ShouldBe(isModified);
     landDetails.Depths[2].Type.ShouldBe("meter");
     landDetails.Depths[2].IsTypeModified.ShouldBe(isModified);
     landDetails.Depths[2].Side.ShouldBe("right");
     landDetails.Depths[2].IsSideModified.ShouldBe(isModified);
 }
예제 #7
0
        public override void ClearAllIsModified()
        {
            base.ClearAllIsModified();

            if (Address != null)
            {
                Address.ClearAllIsModified();
            }
            IsAddressModified = false;

            if (Agents != null)
            {
                foreach (var agent in Agents)
                {
                    agent.ClearAllIsModified();
                }
            }
            IsAgentsModified = false;

            if (Images != null)
            {
                foreach (var image in Images)
                {
                    image.ClearAllIsModified();
                }
            }
            IsImagesModified = false;

            if (FloorPlans != null)
            {
                foreach (var floorPlan in FloorPlans)
                {
                    floorPlan.ClearAllIsModified();
                }
            }
            IsFloorPlansModified = false;

            if (Videos != null)
            {
                foreach (var video in Videos)
                {
                    video.ClearAllIsModified();
                }
            }
            IsVideosModified = false;

            if (Inspections != null)
            {
                foreach (var inspection in Inspections)
                {
                    inspection.ClearAllIsModified();
                }
            }

            if (LandDetails != null)
            {
                LandDetails.ClearAllIsModified();
            }
            IsLandDetailsModified = false;

            if (Features != null)
            {
                Features.ClearAllIsModified();
            }
            IsFeaturesModified = false;

            IsAgencyIdModified    = false;
            IsStatusTypeModified  = false;
            IsCreatedOnModified   = false;
            IsTitleModified       = false;
            IsDescriptionModified = false;
            IsInspectionsModified = false;
            IsLinksModified       = false;
        }
예제 #8
0
        public void Copy(Listing newListing)
        {
            if (newListing == null)
            {
                throw new ArgumentNullException("newListing");
            }

            if (!newListing.IsModified)
            {
                return;
            }

            base.Copy(newListing);

            if (newListing.IsAgencyIdModified)
            {
                AgencyId = newListing.AgencyId;
            }

            if (newListing.IsStatusTypeModified)
            {
                StatusType = newListing.StatusType;
            }

            if (newListing.IsCreatedOnModified)
            {
                CreatedOn = newListing.CreatedOn;
            }

            if (newListing.IsTitleModified)
            {
                Title = newListing.Title;
            }

            if (newListing.IsDescriptionModified)
            {
                Description = newListing.Description;
            }

            if (newListing.IsAddressModified)
            {
                if (newListing.Address == null)
                {
                    Address = null;
                }
                else
                {
                    if (Address == null)
                    {
                        Address = new Address();
                    }

                    if (newListing.Address.IsModified)
                    {
                        Address.Copy(newListing.Address);
                    }

                    IsAddressModified = true;
                }
            }

            if (newListing.IsAgentsModified)
            {
                if (newListing.Agents == null)
                {
                    Agents = null;
                }
                else
                {
                    Agents = new List <ListingAgent>();
                    foreach (var newAgent in newListing.Agents)
                    {
                        var agent = new ListingAgent();
                        agent.Copy(newAgent);
                        Agents.Add(agent);
                    }
                }
            }

            if (newListing.IsImagesModified)
            {
                if (newListing.Images == null)
                {
                    Images = null;
                }
                else
                {
                    Images = new List <Media>();
                    foreach (var newImage in newListing.Images)
                    {
                        var image = new Media();
                        image.Copy(newImage);
                        Images.Add(image);
                    }
                }
            }

            if (newListing.IsFloorPlansModified)
            {
                if (newListing.FloorPlans == null)
                {
                    FloorPlans = null;
                }
                else
                {
                    FloorPlans = new List <Media>();
                    foreach (var newFloorPlan in newListing.FloorPlans)
                    {
                        var floorPlan = new Media();
                        floorPlan.Copy(newFloorPlan);
                        FloorPlans.Add(floorPlan);
                    }
                }
            }

            if (newListing.IsVideosModified)
            {
                if (newListing.Videos == null)
                {
                    Videos = null;
                }
                else
                {
                    Videos = new List <Media>();
                    foreach (var newVideo in newListing.Videos)
                    {
                        var video = new Media();
                        video.Copy(newVideo);
                        Videos.Add(video);
                    }
                }
            }

            if (newListing.IsInspectionsModified)
            {
                if (newListing.Inspections == null)
                {
                    Inspections = null;
                }

                else
                {
                    Inspections = new List <Inspection>();
                    foreach (var newInspection in newListing.Inspections)
                    {
                        var inspection = new Inspection();
                        inspection.Copy(newInspection);
                        Inspections.Add(inspection);
                    }
                }
            }

            if (newListing.IsLandDetailsModified)
            {
                if (newListing.LandDetails == null)
                {
                    LandDetails = null;
                }
                else
                {
                    if (LandDetails == null)
                    {
                        LandDetails = new LandDetails();
                    }

                    if (newListing.LandDetails.IsModified)
                    {
                        LandDetails.Copy(newListing.LandDetails);
                    }

                    IsLandDetailsModified = true;
                }
            }

            if (newListing.IsFeaturesModified)
            {
                if (newListing.Features == null)
                {
                    Features = null;
                }
                else
                {
                    if (Features == null)
                    {
                        Features = new Features();
                    }

                    if (newListing.Features.IsModified)
                    {
                        Features.Copy(newListing.Features);
                    }

                    IsFeaturesModified = true;
                }
            }

            if (newListing.IsLinksModified)
            {
                Links = newListing.Links == null
                    ? null
                    : new List <string>(newListing.Links);
            }
        }
        private static LandDetails ExtractLandDetails(XElement document)
        {
            document.ShouldNotBe(null);

            var landDetailsElement = document.Element("landDetails");
            if (landDetailsElement == null)
            {
                return null;
            }

            var details = new LandDetails
            {
                Area = landDetailsElement.UnitOfMeasureOrDefault("area", "unit"),
                Frontage = landDetailsElement.UnitOfMeasureOrDefault("frontage", "unit"),
                CrossOver = landDetailsElement.ValueOrDefault("crossOver", "value")
            };

            var depthElements = landDetailsElement.Elements("depth").ToArray();
            if (depthElements.Any())
            {
                foreach (var depthElement in depthElements)
                {
                    var depthValue = depthElement.DecimalValueOrDefault();
                    var depthType = depthElement.AttributeValueOrDefault("unit");
                    var depthSide = depthElement.AttributeValueOrDefault("side");

                    if (depthValue > 0)
                    {
                        var depth = new Depth
                        {
                            Value = depthValue,
                            Type = string.IsNullOrWhiteSpace(depthType)
                                ? "Total"
                                : depthType,
                            Side = depthSide
                        };

                        if (details.Depths == null)
                        {
                            details.Depths = new List<Depth>();
                        }

                        details.Depths.Add(depth);
                    }
                }
            }
            
            return details;
        }