diff --git a/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs b/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs index 964f539d98cda904259e5021cf330f55ec297222..4a1ff5ff378b79810d59b8b37512b2ace5cb683a 100644 --- a/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs +++ b/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs @@ -257,5 +257,37 @@ namespace TUGraz.VectoCore.Tests.Reports fh.Close(); } + + + [TestCase()] + public void TestSumDataFileIsLocked() + { + + + var jobFile = @"TestData\Integration\DeclarationMode\Class5_Vocational\Tractor_4x2_vehicle-class-5_EURO6_2018.xml"; + + var sumFilename = Path.Combine(Path.GetDirectoryName(jobFile), "Tractor_4x2_vehicle-class-5_EURO6_2018.vsum"); + + // lock modfile so it can't be written + Stream fh = !File.Exists(sumFilename) ? File.Create(sumFilename) : File.OpenRead(sumFilename); + + var writer = new FileOutputWriter(jobFile); + var inputData = new XMLDeclarationInputDataProvider(jobFile, true); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { + WriteModalResults = true, + ActualModalData = true + }; + var sumWriter = new SummaryDataContainer(writer); + var jobContainer = new JobContainer(sumWriter); + + jobContainer.AddRuns(factory); + + jobContainer.Execute(); + jobContainer.WaitFinished(); + + Assert.AreEqual(2, sumWriter.Table.Rows.Count); + + fh.Close(); + } } }