public void Read_EmptyGeometryBreakWaterTypeAndNullableValuesAreNull_ForeshoreProfileWithoutBreakWaterNaNValues() { // Setup const string name = "testName"; const string id = "testId"; string pointXml = new Point2DCollectionXmlSerializer().ToXml(Enumerable.Empty <Point2D>()); var entity = new ForeshoreProfileEntity { Id = id, Name = name, GeometryXml = pointXml }; var readConversionCollector = new ReadConversionCollector(); // Call ForeshoreProfile foreshoreProfile = entity.Read(readConversionCollector); // Assert Assert.IsNotNull(foreshoreProfile); Assert.AreEqual(id, foreshoreProfile.Id); Assert.AreEqual(name, foreshoreProfile.Name); Assert.IsNaN(foreshoreProfile.Orientation); Assert.IsNaN(foreshoreProfile.X0); Assert.IsNull(foreshoreProfile.BreakWater); Assert.IsFalse(foreshoreProfile.HasBreakWater); CollectionAssert.IsEmpty(foreshoreProfile.Geometry); }
public void Read_GeometryXmlNullOrEmpty_ThrowsArgumentException(string xml) { // Setup var entity = new ForeshoreProfileEntity { GeometryXml = xml }; // Call TestDelegate test = () => entity.Read(new ReadConversionCollector()); // Assert string paramName = Assert.Throws <ArgumentException>(test).ParamName; Assert.AreEqual("xml", paramName); }
public void Read_WithGeometryAndBreakWaterTypeAndValues_CompleteForeshoreProfile() { // Setup const string name = "testName"; const string id = "testId"; var random = new Random(21); int order = random.Next(); double orientation = random.NextDouble(); double x0 = random.NextDouble(); double height = random.NextDouble(); const BreakWaterType breakWaterType = BreakWaterType.Wall; var points = new[] { new Point2D(0, 0) }; string pointXml = new Point2DCollectionXmlSerializer().ToXml(points); var entity = new ForeshoreProfileEntity { Order = order, Id = id, Name = name, Orientation = orientation, X0 = x0, BreakWaterType = Convert.ToByte(breakWaterType), BreakWaterHeight = height, GeometryXml = pointXml }; var readConversionCollector = new ReadConversionCollector(); // Call ForeshoreProfile foreshoreProfile = entity.Read(readConversionCollector); // Assert Assert.IsNotNull(foreshoreProfile); Assert.AreEqual(name, foreshoreProfile.Name); Assert.AreEqual(order, entity.Order); Assert.AreEqual(id, foreshoreProfile.Id); Assert.AreEqual(name, entity.Name); Assert.AreEqual(orientation, foreshoreProfile.Orientation, foreshoreProfile.Orientation.GetAccuracy()); Assert.AreEqual(x0, entity.X0); Assert.AreEqual(breakWaterType, foreshoreProfile.BreakWater.Type); Assert.IsTrue(foreshoreProfile.HasBreakWater); CollectionAssert.AreEqual(points, foreshoreProfile.Geometry); }
public void Read_EntityNotReadBefore_EntityRegistered() { // Setup var collector = new ReadConversionCollector(); var entity = new ForeshoreProfileEntity { Id = "id", GeometryXml = new Point2DCollectionXmlSerializer().ToXml(new Point2D[0]) }; // Precondition Assert.IsFalse(collector.Contains(entity)); // Call entity.Read(collector); // Assert Assert.IsTrue(collector.Contains(entity)); }
private static ForeshoreProfile GetDikeProfileValue(ForeshoreProfileEntity foreshoreProfileEntity, ReadConversionCollector collector) { return(foreshoreProfileEntity?.Read(collector)); }