public void SetDuneLocations_DuneLocationsMatchNameNotAccordingFormat_DuneLocationNotAddedLogMessage(double offset)
        {
            // Setup
            var locationName = $"Location_{offset}";

            var failureMechanism          = new DuneErosionFailureMechanism();
            var readDuneLocation          = new ReadDuneLocation("dune location 1", new Point2D(1.0, 5.3), 8, offset, 2.2, 3.3);
            var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, locationName, 1.0, 5.3);

            // Precondition
            CollectionAssert.IsEmpty(failureMechanism.DuneLocations);

            // Call
            void Call() =>
            DuneErosionDataSynchronizationService.SetDuneLocations(failureMechanism, new[]
            {
                hydraulicBoundaryLocation
            }, new[]
            {
                readDuneLocation
            });

            // Assert
            string expectedMessage = $"Locatie '{locationName}' moet voldoen aan het formaat 'Naam_Vaknummer_Metrering'. " +
                                     "Deze locatie is niet toegevoegd aan de hydraulische belastingen voor het faalmechanisme duinen.";

            TestHelper.AssertLogMessageIsGenerated(Call, expectedMessage, 1);
            CollectionAssert.IsEmpty(failureMechanism.DuneLocations);
        }
        public void SetDuneLocations_DuneLocationOffsetMatchesWithHydraulicBoundaryLocationName_DuneLocationAddedToFailureMechanism()
        {
            // Setup
            var failureMechanism          = new DuneErosionFailureMechanism();
            var readDuneLocation          = new ReadDuneLocation("dune location 1", new Point2D(1.0, 5.3), 8, 1.1, 2.2, 3.3);
            var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "Location_2_1.1", 1.0, 5.3);

            // Precondition
            CollectionAssert.IsEmpty(failureMechanism.DuneLocations);

            // Call
            DuneErosionDataSynchronizationService.SetDuneLocations(
                failureMechanism,
                new[]
            {
                hydraulicBoundaryLocation
            }, new[]
            {
                readDuneLocation
            });

            // Assert
            Assert.AreEqual(1, failureMechanism.DuneLocations.Count());

            DuneLocation duneLocation = failureMechanism.DuneLocations.First();

            Assert.AreEqual(hydraulicBoundaryLocation.Id, duneLocation.Id);
            Assert.AreEqual(readDuneLocation.Name, duneLocation.Name);
            Assert.AreEqual(readDuneLocation.Location, duneLocation.Location);
            Assert.AreEqual(readDuneLocation.Offset, duneLocation.Offset);
            Assert.AreEqual(readDuneLocation.Orientation, duneLocation.Orientation);
            Assert.AreEqual(readDuneLocation.D50, duneLocation.D50);
        }
        public void SetDuneLocations_Always_PreviousDuneLocationsCleared()
        {
            // Setup
            var duneLocation = new TestDuneLocation();

            var failureMechanism = new DuneErosionFailureMechanism();

            failureMechanism.SetDuneLocations(new[]
            {
                duneLocation
            });

            // Precondition
            CollectionAssert.AreEqual(
                new[]
            {
                duneLocation
            }, failureMechanism.DuneLocations);

            // Call
            DuneErosionDataSynchronizationService.SetDuneLocations(failureMechanism,
                                                                   new HydraulicBoundaryLocation[0],
                                                                   new ReadDuneLocation[0]);

            // Assert
            CollectionAssert.IsEmpty(failureMechanism.DuneLocations);
        }
Beispiel #4
0
        public void Replace(IEnumerable <HydraulicBoundaryLocation> newHydraulicBoundaryLocations)
        {
            IEnumerable <ReadDuneLocation> newDuneLocations = duneLocationsReader.ReadDuneLocations();

            DuneErosionDataSynchronizationService.SetDuneLocations(failureMechanism,
                                                                   newHydraulicBoundaryLocations,
                                                                   newDuneLocations);
        }
        public void SetDuneLocations_FailureMechanismNull_ThrowArgumentNullException()
        {
            // Call
            void Call() => DuneErosionDataSynchronizationService.SetDuneLocations(null,
                                                                                  new HydraulicBoundaryLocation[0],
                                                                                  new ReadDuneLocation[0]);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("failureMechanism", exception.ParamName);
        }
        public void SetDuneLocations_DuneLocationsNull_ThrowArgumentNullException()
        {
            // Setup
            var failureMechanism = new DuneErosionFailureMechanism();

            // Call
            void Call() => DuneErosionDataSynchronizationService.SetDuneLocations(failureMechanism,
                                                                                  new HydraulicBoundaryLocation[0],
                                                                                  null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("duneLocations", exception.ParamName);
        }
        public void SetDuneLocation_DuneLocationNoMatchWithHydraulicBoundaryLocation_DuneLocationNotAddedToFailureMechanism(ReadDuneLocation readDuneLocation,
                                                                                                                            HydraulicBoundaryLocation hydraulicBoundaryLocation)
        {
            // Setup
            var failureMechanism = new DuneErosionFailureMechanism();

            // Precondition
            CollectionAssert.IsEmpty(failureMechanism.DuneLocations);

            // Call
            DuneErosionDataSynchronizationService.SetDuneLocations(failureMechanism, new[]
            {
                hydraulicBoundaryLocation
            }, new[]
            {
                readDuneLocation
            });

            // Assert
            CollectionAssert.IsEmpty(failureMechanism.DuneLocations);
        }