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 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 GivenAnAreaWithAMissingType_Validate_ShouldNotHaveAValidationError() { // Arrange. var buildingDetails = new BuildingDetails { Area = new UnitOfMeasure { Type = null, Value = 1m } }; // Act. _buildingDetailsValidator.ShouldHaveChildValidator(building => building.Area, typeof(UnitOfMeasureValidator)); var errors = _buildingDetailsValidator.Validate(buildingDetails); // Assert. errors.Errors.Count.ShouldBe(1); }
private static void AssertBuildingDetails(BuildingDetails buildingDetails, bool isModified) { buildingDetails.Area.Value.ShouldBe(40); buildingDetails.Area.IsValueModified.ShouldBe(isModified); buildingDetails.Area.Type.ShouldBe("square"); buildingDetails.Area.IsTypeModified.ShouldBe(isModified); buildingDetails.IsAreaModified.ShouldBe(isModified); buildingDetails.EnergyRating.ShouldBe(4.5m); }