public void TryReadHydraulicBoundaryLocation_WithHydraulicBoundaryLocationToFindHydraulicBoundaryLocationsContainsLocation_ReturnsTrue()
        {
            // Setup
            const string locationName = "someName";
            const string calculationName = "name";

            string filePath = Path.Combine(readerPath, "validConfiguration.xml");

            var calculationGroup = new CalculationGroup();

            var importer = new CalculationConfigurationImporter(filePath, calculationGroup);

            HydraulicBoundaryLocation expectedLocation = new TestHydraulicBoundaryLocation(locationName);

            // Call
            bool valid = importer.PublicTryReadHydraulicBoundaryLocation(locationName,
                                                                         calculationName,
                                                                         new[]
                                                                         {
                                                                             new TestHydraulicBoundaryLocation("otherNameA"),
                                                                             expectedLocation,
                                                                             new TestHydraulicBoundaryLocation("otherNameB")
                                                                         },
                                                                         out HydraulicBoundaryLocation location);

            // Assert
            Assert.IsTrue(valid);
            Assert.AreSame(expectedLocation, location);
        }
        public void TryReadHydraulicBoundaryLocation_WithHydraulicBoundaryLocationToFindHydraulicBoundaryLocationsEmpty_LogsErrorReturnsFalse()
        {
            // Setup
            string filePath = Path.Combine(readerPath, "validConfiguration.xml");

            var calculationGroup = new CalculationGroup();

            var importer = new CalculationConfigurationImporter(filePath, calculationGroup);

            HydraulicBoundaryLocation location = null;
            var valid = true;

            const string locationName = "someName";
            const string calculationName = "name";

            // Call
            void Validate() => valid = importer.PublicTryReadHydraulicBoundaryLocation(
                                   locationName, calculationName, Enumerable.Empty<HydraulicBoundaryLocation>(), out location);

            // Assert
            var expectedMessage = $"De hydraulische belastingenlocatie '{locationName}' bestaat niet. Berekening '{calculationName}' is overgeslagen.";
            TestHelper.AssertLogMessageWithLevelIsGenerated(Validate, Tuple.Create(expectedMessage, LogLevelConstant.Error));
            Assert.IsFalse(valid);
            Assert.IsNull(location);
        }
        public void TryReadHydraulicBoundaryLocation_NoHydraulicBoundaryLocations_ThrowsArgumentNullException()
        {
            // Setup
            string filePath = Path.Combine(readerPath, "validConfiguration.xml");

            var calculationGroup = new CalculationGroup();

            var importer = new CalculationConfigurationImporter(filePath, calculationGroup);

            // Call
            void Call() => importer.PublicTryReadHydraulicBoundaryLocation(null, "name", null, out HydraulicBoundaryLocation _);

            // Assert
            var exception = Assert.Throws<ArgumentNullException>(Call);
            Assert.AreEqual("hydraulicBoundaryLocations", exception.ParamName);
        }
        public void TryReadHydraulicBoundaryLocation_NoHydraulicBoundaryLocationToFindHydraulicBoundaryLocationsEmpty_ReturnsTrue()
        {
            // Setup
            string filePath = Path.Combine(readerPath, "validConfiguration.xml");

            var calculationGroup = new CalculationGroup();

            var importer = new CalculationConfigurationImporter(filePath, calculationGroup);

            // Call
            bool valid = importer.PublicTryReadHydraulicBoundaryLocation(
                null, "name", Enumerable.Empty<HydraulicBoundaryLocation>(), out HydraulicBoundaryLocation location);

            // Assert
            Assert.IsTrue(valid);
            Assert.IsNull(location);
        }