public void Read_ReadConversionCollectorNull_ThrowArgumentNullException() { // Setup var entity = new DikeProfileEntity(); // Call TestDelegate call = () => entity.Read(null); // Assert string paramName = Assert.Throws <ArgumentNullException>(call).ParamName; Assert.AreEqual("collector", paramName); }
public void Read_AlreadyReadDikeProfileEntity_ReturnDikeProfile() { // Setup var registeredEntity = new DikeProfileEntity(); DikeProfile registeredProfile = DikeProfileTestFactory.CreateDikeProfile(); var collector = new ReadConversionCollector(); collector.Read(registeredEntity, registeredProfile); // Call DikeProfile returnedProfile = registeredEntity.Read(collector); // Assert Assert.AreSame(registeredProfile, returnedProfile); }
public void Read_DikeGeometryXmlNullOrEmpty_ThrowsArgumentException(string xml) { // Setup var profile = new DikeProfileEntity { DikeGeometryXml = xml, ForeshoreXml = validRoughnessPointXml }; // Call TestDelegate test = () => profile.Read(new ReadConversionCollector()); // Assert string paramName = Assert.Throws <ArgumentException>(test).ParamName; Assert.AreEqual("xml", paramName); }
public void Read_DikeProfileEntityWithBreakWater_ReturnDikeProfileWithBreakWater(BreakWaterType type, double height) { // Setup var foreshorePoints = new Point2D[0]; var roughnessPoints = new[] { new RoughnessPoint(new Point2D(1.1, 2.2), 1.0), new RoughnessPoint(new Point2D(3.3, 4.4), 0.6), new RoughnessPoint(new Point2D(5.5, 6.6), 1.0), new RoughnessPoint(new Point2D(7.7, 8.8), 0.5) }; var entity = new DikeProfileEntity { Id = "with_breakwater", Name = "I have a Breakwater!", Orientation = 360.0, BreakWaterHeight = height, BreakWaterType = Convert.ToByte(type), ForeshoreXml = new Point2DCollectionXmlSerializer().ToXml(foreshorePoints), DikeGeometryXml = new RoughnessPointCollectionXmlSerializer().ToXml(roughnessPoints), DikeHeight = 4.5, X = 93.0, Y = 945.6, X0 = 9.34 }; var collector = new ReadConversionCollector(); // Call DikeProfile dikeProfile = entity.Read(collector); // Assert Assert.AreEqual(entity.Id, dikeProfile.Id); Assert.AreEqual(entity.Name, dikeProfile.Name); Assert.AreEqual(entity.Orientation, dikeProfile.Orientation.Value); CollectionAssert.AreEqual(foreshorePoints, dikeProfile.ForeshoreGeometry); CollectionAssert.AreEqual(roughnessPoints, dikeProfile.DikeGeometry, new RoughnessPointComparer()); Assert.AreEqual(entity.X, dikeProfile.WorldReferencePoint.X); Assert.AreEqual(entity.Y, dikeProfile.WorldReferencePoint.Y); Assert.AreEqual(entity.X0, dikeProfile.X0); Assert.AreEqual(height, dikeProfile.BreakWater.Height.Value); Assert.AreEqual(type, dikeProfile.BreakWater.Type); Assert.IsTrue(collector.Contains(entity)); }
public void Read_DikeProfileEntityWithBreakWaterPropertiesNull_ReturnDikeProfileWithoutBreakWater() { // Setup var foreshorePoints = new[] { new Point2D(-9.9, 8.8), new Point2D(-7.7, 5.5) }; var roughnessPoints = new[] { new RoughnessPoint(new Point2D(-7.7, 5.5), 1.0), new RoughnessPoint(new Point2D(5.5, 6.6), 0.5) }; var entity = new DikeProfileEntity { Id = "saved", Name = "Just saved", Orientation = 45.67, BreakWaterHeight = null, BreakWaterType = null, ForeshoreXml = new Point2DCollectionXmlSerializer().ToXml(foreshorePoints), DikeGeometryXml = new RoughnessPointCollectionXmlSerializer().ToXml(roughnessPoints), DikeHeight = 1.2, X = 3.4, Y = 5.6, X0 = -7.8 }; var collector = new ReadConversionCollector(); // Call DikeProfile dikeProfile = entity.Read(collector); // Assert Assert.AreEqual(entity.Id, dikeProfile.Id); Assert.AreEqual(entity.Name, dikeProfile.Name); Assert.AreEqual(entity.Orientation, dikeProfile.Orientation.Value); CollectionAssert.AreEqual(foreshorePoints, dikeProfile.ForeshoreGeometry); CollectionAssert.AreEqual(roughnessPoints, dikeProfile.DikeGeometry, new RoughnessPointComparer()); Assert.AreEqual(entity.X, dikeProfile.WorldReferencePoint.X); Assert.AreEqual(entity.Y, dikeProfile.WorldReferencePoint.Y); Assert.AreEqual(entity.X0, dikeProfile.X0); Assert.IsFalse(dikeProfile.HasBreakWater); }
public void Read_EntityNotReadBefore_EntityRegistered() { // Setup var collector = new ReadConversionCollector(); var entity = new DikeProfileEntity { Id = "id", ForeshoreXml = new Point2DCollectionXmlSerializer().ToXml(new Point2D[0]), DikeGeometryXml = new RoughnessPointCollectionXmlSerializer().ToXml(new RoughnessPoint[0]) }; // Precondition Assert.IsFalse(collector.Contains(entity)); // Call entity.Read(collector); // Assert Assert.IsTrue(collector.Contains(entity)); }
private static DikeProfile GetDikeProfileValue(DikeProfileEntity dikeProfileEntity, ReadConversionCollector collector) { return(dikeProfileEntity?.Read(collector)); }