//-----------------------------------------------------------------------
//
// Copyright (c) 2011 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 System.Linq;
using Deltares.Dam.Data;
namespace Deltares.Dam.TestHelper
{
public static class FactoryForWaterBoard
{
public const string cLocation01Id = "Lcoation01";
///
/// Create waterlevel timeseries
///
///
public static TimeSerieCollection CreateTimeSerieCollectionWithOneLocation()
{
var timeSerieCollection = new TimeSerieCollection();
TimeSerie waterLevelTimeSerie = new TimeSerie();
waterLevelTimeSerie.LocationId = cLocation01Id;
waterLevelTimeSerie.ParameterId = GageDikeProcessor.WaterLevelInputParameterID;
waterLevelTimeSerie.Entries.Add(new TimeSerieEntry(new DateTime(2010, 1, 1), 5));
waterLevelTimeSerie.Entries.Add(new TimeSerieEntry(new DateTime(2010, 1, 2), 6));
waterLevelTimeSerie.Entries.Add(new TimeSerieEntry(new DateTime(2010, 1, 3), 4));
waterLevelTimeSerie.Entries.Add(new TimeSerieEntry(new DateTime(2010, 1, 4), 7));
waterLevelTimeSerie.Entries.Add(new TimeSerieEntry(new DateTime(2010, 1, 5), 5));
timeSerieCollection.Series.Add(waterLevelTimeSerie);
return timeSerieCollection;
}
///
/// Create waterboard job
///
///
public static WaterBoardJob CreateWaterBoardJobWithOneLocationWithoutWaterLevelTimeSeries()
{
Dike dike = new Dike();
var location = new Location();
location.Name = cLocation01Id;
dike.Locations.Add(location);
var waterBoardJob = new WaterBoardJob(null);
DikeJob dikeJob = new DikeJob(dike);
waterBoardJob.Jobs.Add(dikeJob);
LocationJob locationJob = new LocationJob(location);
dikeJob.Jobs.Add(locationJob);
// Make sure waterlevel timeseries are not assigned
foreach (DamJob damJob in dikeJob.Jobs)
{
if (damJob.GetType() == typeof(LocationJob))
{
((LocationJob)damJob).WaterLevelTimeSerie = null;
}
}
return waterBoardJob;
}
///
/// Gets the disposable objects from water board job constructed with .
///
/// The water board job created with .
///
public static IEnumerable GetDisposableObjectsFromWaterBoardJob(WaterBoardJob waterBoardJob)
{
foreach (var dikejob in waterBoardJob.Jobs.Cast())
{
if (dikejob.Subject != null)
{
yield return (Dike)dikejob.Subject;
}
}
}
}
}