public void Constructor_Always_PropertiesSet() { // Call var generalInput = new GeneralWaveImpactAsphaltCoverInput(); // Assert Assert.AreEqual(2, generalInput.DeltaL.NumberOfDecimalPlaces); Assert.AreEqual(1000.0, generalInput.DeltaL, generalInput.DeltaL.GetAccuracy()); Assert.IsFalse(generalInput.ApplyLengthEffectInSection); }
public void DeltaL_SetValidValue_UpdatesValue(double value) { // Setup var generalInput = new GeneralWaveImpactAsphaltCoverInput(); // Call generalInput.DeltaL = (RoundedDouble)value; // Assert Assert.AreEqual(2, generalInput.DeltaL.NumberOfDecimalPlaces); Assert.AreEqual(value, generalInput.DeltaL, generalInput.DeltaL.GetAccuracy()); }
public void DeltaL_SetValueOutsideValidRange_ThrowArgumentOutOfRangeException(double value) { // Setup var generalInput = new GeneralWaveImpactAsphaltCoverInput(); // Call TestDelegate test = () => generalInput.DeltaL = (RoundedDouble)value; // Assert const string expectedMessage = "De waarde voor 'ΔL' moet groter zijn dan 0."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(test, expectedMessage); }
public void Constructor_ExpectedValues() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); mocks.ReplayAll(); var random = new Random(21); var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism { InAssembly = random.NextBoolean(), GeneralWaveImpactAsphaltCoverInput = { ApplyLengthEffectInSection = random.NextBoolean() } }; // Call var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf <WaveImpactAsphaltCoverFailureMechanismPropertiesBase>(properties); Assert.AreSame(failureMechanism, properties.Data); Assert.AreEqual(failureMechanism.Name, properties.Name); Assert.AreEqual(failureMechanism.Code, properties.Code); Assert.AreEqual(failureMechanism.InAssembly, properties.InAssembly); Assert.AreEqual(2, properties.SectionLength.NumberOfDecimalPlaces); Assert.AreEqual(assessmentSection.ReferenceLine.Length, properties.SectionLength, properties.SectionLength.GetAccuracy()); GeneralWaveImpactAsphaltCoverInput generalWaveImpactAsphaltCoverInput = failureMechanism.GeneralWaveImpactAsphaltCoverInput; Assert.AreEqual(2, properties.DeltaL.NumberOfDecimalPlaces); Assert.AreEqual(generalWaveImpactAsphaltCoverInput.DeltaL, properties.DeltaL, properties.DeltaL.GetAccuracy()); Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); Assert.AreEqual(generalWaveImpactAsphaltCoverInput.GetN(assessmentSection.ReferenceLine.Length), properties.N, properties.N.GetAccuracy()); Assert.AreEqual(generalWaveImpactAsphaltCoverInput.ApplyLengthEffectInSection, properties.ApplyLengthEffectInSection); mocks.VerifyAll(); }
public void GetN_SectionLengthNaN_ReturnsNaN() { // Setup var random = new Random(39); var generalInput = new GeneralWaveImpactAsphaltCoverInput { DeltaL = random.NextRoundedDouble() }; // Call double n = generalInput.GetN(double.NaN); // Assert Assert.IsNaN(n); }
public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet(bool inAssembly) { // Setup var random = new Random(); var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism { InAssembly = inAssembly, InAssemblyInputComments = { Body = "Some input text" }, InAssemblyOutputComments = { Body = "Some output text" }, NotInAssemblyComments = { Body = "Really not in assembly" }, CalculationsInputComments = { Body = "Some calculation text" }, GeneralWaveImpactAsphaltCoverInput = { DeltaL = random.NextRoundedDouble(0.1, 2000.0), ApplyLengthEffectInSection = random.NextBoolean() } }; var registry = new PersistenceRegistry(); // Call FailureMechanismEntity entity = failureMechanism.Create(registry); // Assert Assert.IsNotNull(entity); Assert.AreEqual((short)FailureMechanismType.WaveImpactOnAsphaltRevetment, entity.FailureMechanismType); Assert.AreEqual(Convert.ToByte(inAssembly), entity.InAssembly); Assert.AreEqual(failureMechanism.InAssemblyInputComments.Body, entity.InAssemblyInputComments); Assert.AreEqual(failureMechanism.InAssemblyOutputComments.Body, entity.InAssemblyOutputComments); Assert.AreEqual(failureMechanism.NotInAssemblyComments.Body, entity.NotInAssemblyComments); Assert.AreEqual(failureMechanism.CalculationsInputComments.Body, entity.CalculationsInputComments); GeneralWaveImpactAsphaltCoverInput generalInput = failureMechanism.GeneralWaveImpactAsphaltCoverInput; WaveImpactAsphaltCoverFailureMechanismMetaEntity metaEntity = entity.WaveImpactAsphaltCoverFailureMechanismMetaEntities.Single(); Assert.AreEqual(generalInput.DeltaL, metaEntity.DeltaL); Assert.AreEqual(Convert.ToByte(generalInput.ApplyLengthEffectInSection), metaEntity.ApplyLengthEffectInSection); }
public void GetN_DeltaLBiggerThanSectionLength_ReturnsCorrectValue() { // Setup var random = new Random(39); var generalInput = new GeneralWaveImpactAsphaltCoverInput { DeltaL = random.NextRoundedDouble(1001, 99999) }; // Call double n = generalInput.GetN(random.NextDouble(0, 1000)); // Assert Assert.AreEqual(1, n); }
public void GetN_DeltaLSmallerThanSectionLength_ReturnsCorrectValue() { // Setup var random = new Random(39); double sectionLength = random.NextDouble(1001, 99999); RoundedDouble deltaL = random.NextRoundedDouble(0, 1000); var generalInput = new GeneralWaveImpactAsphaltCoverInput { DeltaL = deltaL }; // Call double n = generalInput.GetN(sectionLength); // Assert Assert.AreEqual(sectionLength / deltaL, n, 1e-2); }
public void Read_WithAllData_SetsGeneralInputProperties() { // Setup var random = new Random(); var entity = new WaveImpactAsphaltCoverFailureMechanismMetaEntity { DeltaL = random.NextDouble(1, 2000), ApplyLengthEffectInSection = Convert.ToByte(random.NextBoolean()) }; var generalInput = new GeneralWaveImpactAsphaltCoverInput(); // Call entity.Read(generalInput); // Assert Assert.AreEqual(entity.DeltaL, generalInput.DeltaL, generalInput.DeltaL.GetAccuracy()); Assert.AreEqual(Convert.ToBoolean(entity.ApplyLengthEffectInSection), generalInput.ApplyLengthEffectInSection); }
/// <summary> /// Read the <see cref="WaveImpactAsphaltCoverFailureMechanismMetaEntity"/> and use the information to /// construct a <see cref="GeneralWaveImpactAsphaltCoverInput"/>. /// </summary> /// <param name="entity">The <see cref="WaveImpactAsphaltCoverFailureMechanismMetaEntity"/> to update /// <see cref="GeneralWaveImpactAsphaltCoverInput"/> for.</param> /// <param name="generalInput">The <see cref="GeneralWaveImpactAsphaltCoverInput"/> to update.</param> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> internal static void Read(this WaveImpactAsphaltCoverFailureMechanismMetaEntity entity, GeneralWaveImpactAsphaltCoverInput generalInput) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (generalInput == null) { throw new ArgumentNullException(nameof(generalInput)); } generalInput.DeltaL = (RoundedDouble)entity.DeltaL; generalInput.ApplyLengthEffectInSection = Convert.ToBoolean(entity.ApplyLengthEffectInSection); }