// Copyright (C) Stichting Deltares 2016. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets 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.ObjectModel;
using System.Data.Entity;
using Application.Ringtoets.Storage.DbContext;
using Rhino.Mocks;
namespace Application.Ringtoets.Storage.TestUtil
{
public static class RingtoetsEntitiesHelper
{
///
/// Creates a stub using the given mock repository.
///
/// The mock repository.
/// A stubbed implementation.
public static IRingtoetsEntities Create(MockRepository mockRepository)
{
DbSet projectsSet = CreateEmptyTestDbSet();
DbSet hydraylicLocationsSet = CreateEmptyTestDbSet();
DbSet failureMechanismsSet = CreateEmptyTestDbSet();
DbSet failureMechanismSectionsSet = CreateEmptyTestDbSet();
DbSet failureMechanismSectionPointsSet = CreateEmptyTestDbSet();
DbSet assessmentSectionsSet = CreateEmptyTestDbSet();
DbSet referenceLinesSet = CreateEmptyTestDbSet();
DbSet calculationGroupsSet = CreateEmptyTestDbSet();
DbSet stochasticSoilModelsSet = CreateEmptyTestDbSet();
DbSet stochasticSoilProfilesSet = CreateEmptyTestDbSet();
DbSet soilProfilesSet = CreateEmptyTestDbSet();
DbSet soilLayersSet = CreateEmptyTestDbSet();
DbSet surfaceLinesSet = CreateEmptyTestDbSet();
DbSet surfaceLinePointsSet = CreateEmptyTestDbSet();
DbSet characteristicPointsSet = CreateEmptyTestDbSet();
var ringtoetsEntities = mockRepository.Stub();
ringtoetsEntities.Stub(r => r.ProjectEntities).Return(projectsSet);
ringtoetsEntities.Stub(r => r.HydraulicLocationEntities).Return(hydraylicLocationsSet);
ringtoetsEntities.Stub(r => r.FailureMechanismEntities).Return(failureMechanismsSet);
ringtoetsEntities.Stub(r => r.FailureMechanismSectionEntities).Return(failureMechanismSectionsSet);
ringtoetsEntities.Stub(r => r.FailureMechanismSectionPointEntities).Return(failureMechanismSectionPointsSet);
ringtoetsEntities.Stub(r => r.AssessmentSectionEntities).Return(assessmentSectionsSet);
ringtoetsEntities.Stub(r => r.ReferenceLinePointEntities).Return(referenceLinesSet);
ringtoetsEntities.Stub(r => r.CalculationGroupEntities).Return(calculationGroupsSet);
ringtoetsEntities.Stub(r => r.StochasticSoilModelEntities).Return(stochasticSoilModelsSet);
ringtoetsEntities.Stub(r => r.StochasticSoilProfileEntities).Return(stochasticSoilProfilesSet);
ringtoetsEntities.Stub(r => r.SoilProfileEntities).Return(soilProfilesSet);
ringtoetsEntities.Stub(r => r.SoilLayerEntities).Return(soilLayersSet);
ringtoetsEntities.Stub(r => r.SurfaceLineEntities).Return(surfaceLinesSet);
ringtoetsEntities.Stub(r => r.SurfaceLinePointEntities).Return(surfaceLinePointsSet);
ringtoetsEntities.Stub(r => r.CharacteristicPointEntities).Return(characteristicPointsSet);
return ringtoetsEntities;
}
private static DbSet CreateEmptyTestDbSet() where T : class
{
return new TestDbSet(new ObservableCollection());
}
}
}