// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System.Collections.Generic; using System.IO; using Deltares.Dam.Data; using Deltares.Dam.Data.Exporters; using NUnit.Framework; using Rhino.Mocks; namespace Deltares.Dam.Tests.Exporters { [TestFixture] public class ScenarioExporterTest { private const string FileNameWithoutExtension = "ScenarioExportTestFile"; private const string FileName = FileNameWithoutExtension + ".shp"; private MockRepository mocks;private IScenarioExporter exporter; private ILocationJob job; #region Setup [TestFixtureSetUp] public void FixtureSetup() { mocks = new MockRepository(); job = mocks.DynamicMock(); // remove old files var files = Directory.GetFiles(Directory.GetCurrentDirectory(), FileNameWithoutExtension + "*.*"); foreach (var file in files) { File.Delete(file); } } [TestFixtureTearDown] public void FixtureTearDown() { } [SetUp] public void TestSetup() { } [TearDown] public void TestTearDown() { mocks.VerifyAll(); } #endregion [Test] [Ignore("Need to fix shape file writing")] public void Export2ShapeFile_NormalScenario_ValidShapeFileExists() { var jobs = new List() { job }; using (var locationStubReturn = new Location() { XRd = 1.9, YRd = 2.5 }) { Expect.Call(job.Location).Return(locationStubReturn); Expect.Call(job.HasRWScenarioResults).Return(true); Expect.Call(job.RWScenarioResults).Return(new[] { new RWScenarioResult() { SafetyFactor = 1.7 } }); mocks.ReplayAll(); var file = new FileInfo(FileName); exporter = new ScenarioExporter(jobs, file); exporter.Export(); Assert.IsTrue(File.Exists(FileName)); // open and read/test the file contents?? } } } }