public void TryReadStructure_WithStructureToFindStructuresContainsStructure_ReturnsTrue()
        {
            // Setup
            const string structureId = "someId";
            const string calculationName = "name";

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

            var calculationGroup = new CalculationGroup();

            var importer = new CalculationConfigurationImporter(filePath, calculationGroup);

            var expectedProfile = new TestStructure(structureId);

            // Call
            bool valid = importer.PublicTryReadStructure(structureId,
                                                         calculationName,
                                                         new[]
                                                         {
                                                             new TestStructure("otherIdA"),
                                                             expectedProfile,
                                                             new TestStructure("otherIdB")
                                                         },
                                                         out StructureBase structure);

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

            var calculationGroup = new CalculationGroup();

            var importer = new CalculationConfigurationImporter(filePath, calculationGroup);

            StructureBase structure = null;
            var valid = true;

            const string structureId = "someAwesomeId";
            const string calculationName = "name";

            // Call
            void Validate() => valid = importer.PublicTryReadStructure(
                                   structureId, calculationName, Enumerable.Empty<StructureBase>(), out structure);

            // Assert
            var expectedMessage = $"Het kunstwerk met ID '{structureId}' bestaat niet. Berekening '{calculationName}' is overgeslagen.";
            TestHelper.AssertLogMessageWithLevelIsGenerated(Validate, Tuple.Create(expectedMessage, LogLevelConstant.Error));
            Assert.IsFalse(valid);
            Assert.IsNull(structure);
        }
        public void TryReadStructure_NoStructures_ThrowsArgumentNullException()
        {
            // Setup
            string filePath = Path.Combine(readerPath, "validConfiguration.xml");

            var calculationGroup = new CalculationGroup();

            var importer = new CalculationConfigurationImporter(filePath, calculationGroup);

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

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

            var calculationGroup = new CalculationGroup();

            var importer = new CalculationConfigurationImporter(filePath, calculationGroup);

            // Call
            bool valid = importer.PublicTryReadStructure(null, "name", Enumerable.Empty<StructureBase>(),
                                                         out StructureBase structure);

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