// Copyright (C) Stichting Deltares 2017. 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;
using System.Linq;
using Core.Common.Base.IO;
using Core.Common.Gui.Plugin;
using Core.Common.TestUtil;
using Core.Common.Util;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Revetment.IO.Configurations;
using Ringtoets.WaveImpactAsphaltCover.Data;
using Ringtoets.WaveImpactAsphaltCover.Forms.PresentationObjects;
using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources;
namespace Ringtoets.WaveImpactAsphaltCover.Plugin.Test.ExportInfos
{
[TestFixture]
public class WaveImpactAsphaltCoverWaveConditionsCalculationContextConfigurationExportInfoTest
{
private ExportInfo exportInfo;
[SetUp]
public void Setup()
{
using (var plugin = new WaveImpactAsphaltCoverPlugin())
{
exportInfo = plugin.GetExportInfos()
.Single(ei => ei.DataType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationContext)
&& ei.Name.Equals("Ringtoets berekeningenconfiguratie"));
}
}
[Test]
public void Initialized_Always_ExpectedPropertiesSet()
{
// Assert
Assert.IsNotNull(exportInfo.CreateFileExporter);
Assert.IsNotNull(exportInfo.IsEnabled);
Assert.AreEqual("Algemeen", exportInfo.Category);
TestHelper.AssertImagesAreEqual(CoreCommonGuiResources.ExportIcon, exportInfo.Image);
Assert.IsNotNull(exportInfo.FileFilterGenerator);
}
[Test]
public void CreateFileExporter_Always_ReturnFileExporter()
{
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.Stub();
mocks.ReplayAll();
var random = new Random(21);
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
{
InputParameters =
{
CategoryType = random.NextEnumValue()
}
};
var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(calculation,
new CalculationGroup(),
new WaveImpactAsphaltCoverFailureMechanism(),
assessmentSection);
// Call
IFileExporter fileExporter = exportInfo.CreateFileExporter(context, "test");
// Assert
Assert.IsInstanceOf(fileExporter);
mocks.VerifyAll();
}
[Test]
public void FileFilterGenerator_Always_ReturnFileFilter()
{
// Call
FileFilterGenerator fileFilterGenerator = exportInfo.FileFilterGenerator;
// Assert
Assert.AreEqual("Ringtoets berekeningenconfiguratie (*.xml)|*.xml", fileFilterGenerator.Filter);
}
[Test]
public void IsEnabled_Always_ReturnTrue()
{
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.Stub();
mocks.ReplayAll();
var context = new WaveImpactAsphaltCoverWaveConditionsCalculationContext(new WaveImpactAsphaltCoverWaveConditionsCalculation(),
new CalculationGroup(),
new WaveImpactAsphaltCoverFailureMechanism(),
assessmentSection);
// Call
bool isEnabled = exportInfo.IsEnabled(context);
// Assert
Assert.IsTrue(isEnabled);
mocks.VerifyAll();
}
}
}