public void Create_DikeProfileAlreadyRegistered_ReturnRegisteredEntity() { // Setup DikeProfile dikeProfile = DikeProfileTestFactory.CreateDikeProfile(); var registry = new PersistenceRegistry(); DikeProfileEntity entity1 = dikeProfile.Create(registry, 0); // Precondition: Assert.IsTrue(registry.Contains(dikeProfile)); // Call DikeProfileEntity entity2 = dikeProfile.Create(registry, 0); // Assert Assert.AreSame(entity1, entity2); }
public void Create_StringPropertiesDoNotShareReference() { // Setup const string originalId = "no_breakwater"; const string originalName = "Dike profile without break water."; var dikeProfile = new DikeProfile(new Point2D(1.1, 2.2), new RoughnessPoint[0], new Point2D[0], null, new DikeProfile.ConstructionProperties { Id = originalId, Name = originalName }); var registry = new PersistenceRegistry(); // Call DikeProfileEntity entity = dikeProfile.Create(registry, 0); // Assert Assert.AreNotSame(originalName, entity.Name, "To create stable binary representations/fingerprints, it's really important that strings are not shared."); Assert.AreEqual(originalName, entity.Name); Assert.AreNotSame(originalId, entity.Id, "To create stable binary representations/fingerprints, it's really important that strings are not shared."); Assert.AreEqual(originalId, entity.Id); }
private static void AddEntitiesForDikeProfiles(GrassCoverErosionInwardsFailureMechanism mechanism, PersistenceRegistry registry, FailureMechanismEntity entity) { for (var i = 0; i < mechanism.DikeProfiles.Count; i++) { DikeProfile dikeProfile = mechanism.DikeProfiles[i]; entity.DikeProfileEntities.Add(dikeProfile.Create(registry, i)); } }
public void Create_RegistryIsNull_ThrowArgumentNullException() { // Setup DikeProfile dikeProfile = DikeProfileTestFactory.CreateDikeProfile(); // Call TestDelegate call = () => dikeProfile.Create(null, 0); // Assert string paramName = Assert.Throws <ArgumentNullException>(call).ParamName; Assert.AreEqual("registry", paramName); }
public void Create_WithoutBreakWater_ReturnEntityWithNullBreakWaterProperties() { // Setup int order = new Random(22).Next(); var dikeProfile = new DikeProfile(new Point2D(1.1, 2.2), new[] { new RoughnessPoint(new Point2D(3.3, 4.4), 0.75), new RoughnessPoint(new Point2D(5.5, 6.6), 0.75) }, new[] { new Point2D(7.7, 8.8), new Point2D(9.9, 10.10) }, null, new DikeProfile.ConstructionProperties { Id = "no_breakwater", Name = "Dike profile without break water.", DikeHeight = 11.11, Orientation = 12.12, X0 = 13.13 }); var registry = new PersistenceRegistry(); // Call DikeProfileEntity entity = dikeProfile.Create(registry, order); // Assert Assert.AreEqual(dikeProfile.WorldReferencePoint.X, entity.X); Assert.AreEqual(dikeProfile.WorldReferencePoint.Y, entity.Y); Assert.AreEqual(dikeProfile.X0, entity.X0); Assert.AreEqual(order, entity.Order); string convertedDikeGeometry = new RoughnessPointCollectionXmlSerializer().ToXml(dikeProfile.DikeGeometry); Assert.AreEqual(convertedDikeGeometry, entity.DikeGeometryXml); string convertedForeshoreGeometry = new Point2DCollectionXmlSerializer().ToXml(dikeProfile.ForeshoreGeometry); Assert.AreEqual(convertedForeshoreGeometry, entity.ForeshoreXml); Assert.AreEqual(dikeProfile.Orientation.Value, entity.Orientation); Assert.AreEqual(dikeProfile.DikeHeight.Value, entity.DikeHeight); Assert.AreEqual(dikeProfile.Id, entity.Id); Assert.AreEqual(dikeProfile.Name, entity.Name); Assert.IsNull(entity.BreakWaterHeight); Assert.IsNull(entity.BreakWaterType); }
public void Create_WithBreakWater_ReturnEntity(BreakWaterType type, double height) { // Setup int order = new Random(42).Next(); var dikeProfile = new DikeProfile(new Point2D(1234.4567, 5678.432), new[] { new RoughnessPoint(new Point2D(-6.6, -3.3), 0.75), new RoughnessPoint(new Point2D(4.4, 5.5), 0.75) }, new[] { new Point2D(-12.12, -13.13), new Point2D(-6.6, -3.3) }, new BreakWater(type, height), new DikeProfile.ConstructionProperties { Id = "no_breakwater", Name = "Dike profile without break water.", DikeHeight = 98.76, Orientation = 76.54, X0 = -12.34 }); var registry = new PersistenceRegistry(); // Call DikeProfileEntity entity = dikeProfile.Create(registry, order); // Assert Assert.AreEqual(dikeProfile.WorldReferencePoint.X, entity.X); Assert.AreEqual(dikeProfile.WorldReferencePoint.Y, entity.Y); Assert.AreEqual(dikeProfile.X0, entity.X0); Assert.AreEqual(order, entity.Order); string convertedDikeGeometry = new RoughnessPointCollectionXmlSerializer().ToXml(dikeProfile.DikeGeometry); Assert.AreEqual(convertedDikeGeometry, entity.DikeGeometryXml); string convertedForeshoreGeometry = new Point2DCollectionXmlSerializer().ToXml(dikeProfile.ForeshoreGeometry); Assert.AreEqual(convertedForeshoreGeometry, entity.ForeshoreXml); Assert.AreEqual(dikeProfile.Orientation.Value, entity.Orientation); Assert.AreEqual(dikeProfile.DikeHeight.Value, entity.DikeHeight); Assert.AreEqual(dikeProfile.Id, entity.Id); Assert.AreEqual(dikeProfile.Name, entity.Name); Assert.AreEqual((byte)type, entity.BreakWaterType); Assert.AreEqual(height, entity.BreakWaterHeight); }