Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs =================================================================== diff -u -re140ea953f768b1f99d1fd70a2e87d00408416fe -re6972847cef019302b4fe9f7dd45d09175ef6cea --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs (.../MacroStabilityInwardsCalculationGroupExporter.cs) (revision e140ea953f768b1f99d1fd70a2e87d00408416fe) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs (.../MacroStabilityInwardsCalculationGroupExporter.cs) (revision e6972847cef019302b4fe9f7dd45d09175ef6cea) @@ -134,9 +134,10 @@ private static bool HasChildrenWithOutput(CalculationGroup nestedGroup) { - MacroStabilityInwardsCalculation[] calculations = nestedGroup.Children.OfType() + MacroStabilityInwardsCalculation[] calculations = nestedGroup.GetCalculations() + .Cast() .ToArray(); - return calculations.Any() && calculations.All(calculation => calculation.HasOutput); + return calculations.Any() && calculations.Any(calculation => calculation.HasOutput); } private static void CreateDirectory(string currentFolderPath) Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Exporters/MacroStabilityInwardsCalculationGroupExporterTest.cs =================================================================== diff -u -re140ea953f768b1f99d1fd70a2e87d00408416fe -re6972847cef019302b4fe9f7dd45d09175ef6cea --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Exporters/MacroStabilityInwardsCalculationGroupExporterTest.cs (.../MacroStabilityInwardsCalculationGroupExporterTest.cs) (revision e140ea953f768b1f99d1fd70a2e87d00408416fe) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Exporters/MacroStabilityInwardsCalculationGroupExporterTest.cs (.../MacroStabilityInwardsCalculationGroupExporterTest.cs) (revision e6972847cef019302b4fe9f7dd45d09175ef6cea) @@ -612,6 +612,54 @@ } [Test] + public void Export_NestedCalculationGroupWithGroupsWithCalculationsWithAndWithoutOutput_FolderNotExportedAndReturnsTrue() + { + // Setup + string folderPath = TestHelper.GetScratchPadPath($"{nameof(MacroStabilityInwardsCalculationGroupExporterTest)}.{nameof(Export_NestedCalculationGroupWithGroupsWithCalculationsWithAndWithoutOutput_FolderNotExportedAndReturnsTrue)}"); + Directory.CreateDirectory(folderPath); + + MacroStabilityInwardsCalculationScenario calculation1 = CreateCalculation("calculation1", false); + MacroStabilityInwardsCalculationScenario calculation2 = CreateCalculation("calculation2"); + + var rootGroup = new CalculationGroup + { + Name = "root" + }; + var nestedGroup1 = new CalculationGroup + { + Name = "group1" + }; + var nestedGroup2 = new CalculationGroup + { + Name = "group2" + }; + nestedGroup2.Children.Add(calculation2); + nestedGroup2.Children.Add(calculation1); + nestedGroup1.Children.Add(nestedGroup2); + rootGroup.Children.Add(nestedGroup1); + + var exporter = new MacroStabilityInwardsCalculationGroupExporter(rootGroup, new PersistenceFactory(), folderPath, fileExtension, c => AssessmentSectionTestHelper.GetTestAssessmentLevel()); + + try + { + using (new MacroStabilityInwardsCalculatorFactoryConfig()) + { + // Call + bool exportResult = exporter.Export(); + + // Assert + Assert.IsTrue(exportResult); + Assert.IsFalse(File.Exists(Path.Combine(folderPath, nestedGroup1.Name, nestedGroup2.Name, $"{calculation1.Name}.{fileExtension}"))); + AssertCalculationExists(Path.Combine(folderPath, nestedGroup1.Name, nestedGroup2.Name, $"{calculation2.Name}.{fileExtension}")); + } + } + finally + { + Directory.Delete(folderPath, true); + } + } + + [Test] public void Export_ErrorDuringSingleCalculationExport_LogsErrorAndReturnsFalse() { // Setup