// 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.ComponentModel;
using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Probability;
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Common.Forms.PropertyClasses;
namespace Ringtoets.Common.Forms.Test.PropertyClasses
{
[TestFixture]
public class FailureMechanismSectionProbabilityAssessmentPropertiesTest
{
[Test]
public void Constructor_ProbabilityAssessmentInputNull_ThrowsArgumentNullException()
{
// Setup
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
// Call
TestDelegate call = () => new FailureMechanismSectionProbabilityAssessmentProperties(section, null);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("probabilityAssessmentInput", exception.ParamName);
}
[Test]
public void Constructor_ExpectedValues()
{
// Setup
var mocks = new MockRepository();
var probabilityAssessmentInput = mocks.Stub();
probabilityAssessmentInput.Stub(pai => pai.A).Return(0.5);
probabilityAssessmentInput.Stub(pai => pai.B).Return(100);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
// Call
var properties = new FailureMechanismSectionProbabilityAssessmentProperties(section, probabilityAssessmentInput);
// Assert
Assert.IsInstanceOf(properties);
Assert.AreSame(section, properties.Data);
TestHelper.AssertTypeConverter();
Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces);
Assert.AreEqual(1.0, properties.N, properties.N.GetAccuracy());
mocks.VerifyAll();
}
[Test]
public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
{
// Setup
var mocks = new MockRepository();
var probabilityAssessmentInput = mocks.Stub();
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
// Call
var properties = new FailureMechanismSectionProbabilityAssessmentProperties(section, probabilityAssessmentInput);
// Assert
PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
Assert.AreEqual(5, dynamicProperties.Count);
PropertyDescriptor nameProperty = dynamicProperties[0];
PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
"Algemeen",
"Vaknaam",
"De naam van het vak.",
true);
PropertyDescriptor lengthProperty = dynamicProperties[1];
PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lengthProperty,
"Algemeen",
"Lengte [m]",
"De totale lengte van het vak in meters.",
true);
PropertyDescriptor startPointProperty = dynamicProperties[2];
PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(startPointProperty,
"Algemeen",
"Beginpunt",
"Beginpunt van het vak (X-coördinaat, Y-coördinaat).",
true);
PropertyDescriptor endPointProperty = dynamicProperties[3];
PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(endPointProperty,
"Algemeen",
"Eindpunt",
"Eindpunt van het vak (X-coördinaat, Y-coördinaat).",
true);
PropertyDescriptor NProperty = dynamicProperties[4];
PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(NProperty,
"Algemeen",
"N* [-]",
"Vakspecifieke waarde voor het in rekening brengen van " +
"het lengte-effect tijdens assemblage (afgerond).",
true);
mocks.VerifyAll();
}
[Test]
public void ToString_ValidData_ReturnSectionName()
{
// Setup
var mocks = new MockRepository();
var probabilityAssessmentInput = mocks.Stub();
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var properties = new FailureMechanismSectionProbabilityAssessmentProperties(section, probabilityAssessmentInput);
// Call
string toString = properties.ToString();
// Assert
Assert.AreEqual(section.Name, toString);
mocks.VerifyAll();
}
}
}