Пример #1
0
        public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
        {
            // Setup
            var       mocks                     = new MockRepository();
            var       projectObserver           = mocks.StrictMock <IObserver>();
            const int numberOfChangedProperties = 3;

            projectObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties);
            mocks.ReplayAll();

            var random           = new Random(21);
            var failureMechanism = new SpecificFailureMechanism
            {
                InAssembly = random.NextBoolean()
            };

            // Call
            var properties = new SpecificFailureMechanismProperties(failureMechanism);

            failureMechanism.Attach(projectObserver);

            // Call
            const string  newName = "Some new cool pretty name";
            const string  newCode = "Nieuw Faalmechanisme";
            RoundedDouble newN    = random.NextRoundedDouble(1.0, 20.0);

            properties.Name = newName;
            properties.Code = newCode;
            properties.N    = newN;

            // Assert
            Assert.AreEqual(newName, failureMechanism.Name);
            Assert.AreEqual(newCode, failureMechanism.Code);

            GeneralInput input = failureMechanism.GeneralInput;

            Assert.AreEqual(newN, input.N, input.N.GetAccuracy());

            mocks.VerifyAll();
        }
Пример #2
0
        public void ApplyLengthEffectInSection_SetNewValue_NotifyObservers()
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var failureMechanism = new SpecificFailureMechanism();

            failureMechanism.Attach(observer);

            var properties = new SpecificFailureMechanismProperties(failureMechanism);

            // Call
            properties.ApplyLengthEffectInSection = true;

            // Assert
            Assert.IsTrue(failureMechanism.GeneralInput.ApplyLengthEffectInSection);
            mocks.VerifyAll();
        }
Пример #3
0
        public void OnNodeRenamed_ChangesNameOfFailureMechanismAndNotifiesObservers()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var observer          = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            var failureMechanism = new SpecificFailureMechanism();

            failureMechanism.Attach(observer);

            var context = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

            const string newName = "Updated FailureMechanism name";

            // Call
            info.OnNodeRenamed(context, newName);

            // Assert
            Assert.AreEqual(newName, failureMechanism.Name);
        }
Пример #4
0
        public void N_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double newN)
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            mocks.ReplayAll();

            var failureMechanism = new SpecificFailureMechanism();

            failureMechanism.Attach(observer);

            var properties = new SpecificFailureMechanismProperties(failureMechanism);

            // Call
            void Call() => properties.N = (RoundedDouble)newN;

            // Assert
            const string expectedMessage = "De waarde voor 'N' moet in het bereik [1,00, 20,00] liggen.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(Call, expectedMessage);

            mocks.VerifyAll();
        }