public void Export_CalculationsWithoutOutput_FileWithOnlyHeader() { // Setup const string folderName = nameof(Export_CalculationsWithoutOutput_FileWithOnlyHeader); string directoryPath = TestHelper.GetScratchPadPath(folderName); using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), folderName)) { string filePath = Path.Combine(directoryPath, "test.csv"); var calculationsWithoutOutput = new[] { new StabilityStoneCoverWaveConditionsCalculation() }; var exporter = new StabilityStoneCoverWaveConditionsExporter(calculationsWithoutOutput, filePath, i => "1/100"); // Call bool isExported = exporter.Export(); // Assert Assert.IsTrue(isExported); Assert.IsTrue(File.Exists(filePath)); string fileContent = File.ReadAllText(filePath); string expectedText = $"Naam berekening; Naam HB locatie; X HB locatie (RD) [m]; Y HB locatie (RD) [m]; Naam voorlandprofiel; Dam gebruikt; Voorlandgeometrie gebruikt; Type bekleding; Doelkans [1/jaar]; Waterstand [m+NAP]; Golfhoogte (Hs) [m]; Golfperiode (Tp) [s]; Golfrichting t.o.v. dijknormaal [°]; Golfrichting t.o.v. Noord [°]{Environment.NewLine}"; Assert.AreEqual(expectedText, fileContent); } }
public void Constructor_ValidParameters_ExpectedValues() { // Setup string filePath = TestHelper.GetScratchPadPath("test.csv"); // Call var exporter = new StabilityStoneCoverWaveConditionsExporter(Array.Empty <StabilityStoneCoverWaveConditionsCalculation>(), filePath, i => "1/100"); // Assert Assert.IsInstanceOf <WaveConditionsExporterBase>(exporter); }
public void Export_ValidDataWithCalculationTypeBoth_ValidFile() { // Setup string folderName = $"{nameof(StabilityStoneCoverWaveConditionsExporterTest)}.{nameof(Export_ValidDataWithCalculationTypeBoth_ValidFile)}"; string directoryPath = TestHelper.GetScratchPadPath(folderName); using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), folderName)) { string filePath = Path.Combine(directoryPath, "test.csv"); var calculations = new[] { new StabilityStoneCoverWaveConditionsCalculation { Name = "aCalculation", InputParameters = { HydraulicBoundaryLocation = new HydraulicBoundaryLocation(8, "aLocation", 44, 123.456), ForeshoreProfile = new TestForeshoreProfile("foreshoreA"), LowerBoundaryRevetment = (RoundedDouble)1.384, UpperBoundaryRevetment = (RoundedDouble)11.54898963, StepSize = WaveConditionsInputStepSize.Half, LowerBoundaryWaterLevels = (RoundedDouble)1.98699, UpperBoundaryWaterLevels = (RoundedDouble)84.26548, CalculationType = StabilityStoneCoverWaveConditionsCalculationType.Both }, Output = StabilityStoneCoverWaveConditionsOutputTestFactory.Create(new[] { new TestWaveConditionsOutput() }, new[] { new TestWaveConditionsOutput() }) } }; var exporter = new StabilityStoneCoverWaveConditionsExporter(calculations, filePath, i => "1/100"); // Call bool isExported = exporter.Export(); // Assert Assert.IsTrue(isExported); Assert.IsTrue(File.Exists(filePath)); string fileContent = File.ReadAllText(filePath); string expectedText = $"Naam berekening; Naam HB locatie; X HB locatie (RD) [m]; Y HB locatie (RD) [m]; Naam voorlandprofiel; Dam gebruikt; Voorlandgeometrie gebruikt; Type bekleding; Doelkans [1/jaar]; Waterstand [m+NAP]; Golfhoogte (Hs) [m]; Golfperiode (Tp) [s]; Golfrichting t.o.v. dijknormaal [°]; Golfrichting t.o.v. Noord [°]{Environment.NewLine}" + $"aCalculation; aLocation; 44.000; 123.456; foreshoreA; nee; nee; Steen (blokken); 1/100; 1.10; 2.20; 3.30; 4.40; 5.50{Environment.NewLine}" + $"aCalculation; aLocation; 44.000; 123.456; foreshoreA; nee; nee; Steen (zuilen); 1/100; 1.10; 2.20; 3.30; 4.40; 5.50{Environment.NewLine}"; Assert.AreEqual(expectedText, fileContent); } }