// Copyright (C) Stichting Deltares 2025. 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 System.Linq;
using Deltares.Dam.Data;
using Deltares.Dam.Data.DataPlugins;
using Deltares.Dam.Data.DataPlugins.Configuration;
using Deltares.Maps;
using NUnit.Framework;
namespace Deltares.Dam.Tests
{
[TestFixture]
public class DataPluginImporterBackgroundTests
{
private DataPluginImporter importer;
private IEnumerable dataSources;
[Test]
// Precondition : Data source should be set up correctly
// Precondition : File contains data
// Precondition : Importer has read all data
public void ImporterGetIdList_InvokedOnClient_ReturnsNonEmptyList()
{
importer.ImportDataForDike(null);
IEnumerable idlist = importer.MapGeometryIdList;
Assert.That(idlist, Is.Not.Null);
Assert.That(idlist.Any(), Is.True);
}
[Test]
// Precondition : Data source should be set up correctly
// Precondition : File contains data
// Precondition : Importer has read all data
public void ImporterGetGeometry_InvokedOnClient_ReturnsGeometry()
{
importer.ImportDataForDike(null);
IEnumerable idlist = importer.MapGeometryIdList;
Assert.That(importer.GetMapGeometry(idlist.ElementAt(0)), Is.Not.Null);
}
[Test]
// Precondition : Data source should be set up correctly
// Precondition : File contains data
// Precondition : Importer has read all data
public void ImporterGetGeometryAttributes_InvokedOnClient_ReturnsAttributeList()
{
importer.ImportDataForDike(null);
IEnumerable idlist = importer.MapGeometryIdList;
Assert.That(importer.GetMapGeometryAttributes(idlist.ElementAt(0)), Is.Not.Null);
}
#region Setup
[SetUp]
public void FixtureSetup()
{
string testDataFolder = Path.Combine(Directory.GetCurrentDirectory(), @"TestData\ShapeFiles\Gemeenten.shp");
var testFile = new ShapeFileLocation(testDataFolder);
Assert.That(testFile.IsValid, Is.True);
dataSources = new List
{
new DataSource
{
DataSourceType = DataSourceType.BackgroundShapeFiles,
DataLocation = testFile.FullPath
}
};
}
[TearDown]
public void FixtureTearDown() {}
[SetUp]
public void TestSetup()
{
importer = new DataPluginImporter();
importer.SetDataSources("", dataSources);
}
[TearDown]
public void TestTearDown()
{
importer = null;
}
#endregion
}
}