//-----------------------------------------------------------------------
//
// Copyright (c) 2009 Deltares. All rights reserved.
//
// B.S.T.I.M. The
// tom.the@deltares.nl
// 16-2-2011
// n.a.
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using Deltares.Dam.TestHelper;
using Deltares.Standard.Extensions;
namespace Deltares.Dam.Tests
{
using NUnit.Framework;
using Deltares.Dam.Data;
[TestFixture]
public class WaterBoardJobImporterTest
{
private IList disposables;
[SetUp]
public void SetUp()
{
disposables = new List();
}
[TearDown]
public void TearDown()
{
foreach (var disposable in disposables)
{
disposable.Dispose();
}
disposables = null;
}
[Test]
public void IsTimeSeriesNotImportedIntoLocationWhenNoMatchingId()
{
// Create waterBoardJob with location without waterlevels
WaterBoardJob waterBoardJob = FactoryForWaterBoard.CreateWaterBoardJobWithOneLocationWithoutWaterLevelTimeSeries();
disposables.AddRange(FactoryForWaterBoard.GetDisposableObjectsFromWaterBoardJob(waterBoardJob));
// Assign other name to location to prevent timeserie assignment
((LocationJob) ((DikeJob) waterBoardJob.Jobs[0]).Jobs[0]).Location.Name = "Othername";
TimeSerieCollection timeSerieCollection = FactoryForWaterBoard.CreateTimeSerieCollectionWithOneLocation();
// Check if waterlevels assigned
WaterBoardJobImporter.ImportWaterlevels(waterBoardJob, timeSerieCollection);
Assert.IsFalse(waterBoardJob.AreAllDikeLocationsWaterLevelTimeSeriesAssigned(), "Check if waterlevels assigned");
}
[Test]
public void AreTimeSeriesImportedIntoLocations()
{
// Create waterBoardJob with location without waterlevels
WaterBoardJob waterBoardJob = FactoryForWaterBoard.CreateWaterBoardJobWithOneLocationWithoutWaterLevelTimeSeries();
disposables.AddRange(FactoryForWaterBoard.GetDisposableObjectsFromWaterBoardJob(waterBoardJob));
TimeSerieCollection timeSerieCollection = FactoryForWaterBoard.CreateTimeSerieCollectionWithOneLocation();
// Check if waterlevels assigned
WaterBoardJobImporter.ImportWaterlevels(waterBoardJob, timeSerieCollection);
Assert.IsTrue(waterBoardJob.AreAllDikeLocationsWaterLevelTimeSeriesAssigned(), "Check if waterlevels assigned");
}
}
}