public void Create_WithValidData_ReturnsPersistableDataModel() { // Setup const string filePath = "ValidFilePath"; MacroStabilityInwardsCalculationScenario calculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation()); calculation.Output = MacroStabilityInwardsOutputTestFactory.CreateRandomOutput(); using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call PersistableDataModel persistableDataModel = PersistableDataModelFactory.Create(calculation, new GeneralMacroStabilityInwardsInput(), AssessmentSectionTestHelper.GetTestAssessmentLevel, filePath); // Assert PersistableDataModelTestHelper.AssertPersistableDataModel(calculation, filePath, persistableDataModel); } }
public void Export_RunsSuccessful_SetsDataCorrectlyAndReturnsTrue() { // Setup string filePath = TestHelper.GetScratchPadPath($"{nameof(MacroStabilityInwardsCalculationExporterTest)}.{nameof(Export_RunsSuccessful_SetsDataCorrectlyAndReturnsTrue)}.ValidFile.stix"); MacroStabilityInwardsCalculationScenario calculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation()); calculation.Output = MacroStabilityInwardsOutputTestFactory.CreateRandomOutput(); var persistenceFactory = new MacroStabilityInwardsTestPersistenceFactory { WriteFile = true }; var exporter = new MacroStabilityInwardsCalculationExporter(calculation, new GeneralMacroStabilityInwardsInput(), persistenceFactory, filePath, AssessmentSectionTestHelper.GetTestAssessmentLevel); try { using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call bool exportResult = exporter.Export(); // Assert PersistableDataModelTestHelper.AssertPersistableDataModel(calculation, filePath, persistenceFactory.PersistableDataModel); Assert.AreEqual($"{filePath}.temp", persistenceFactory.FilePath); var persister = (MacroStabilityInwardsTestPersister)persistenceFactory.CreatedPersister; Assert.IsTrue(persister.PersistCalled); Assert.IsTrue(exportResult); } } finally { File.Delete(filePath); } }