public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var mocks            = new MockRepository();
            var failureMechanism = mocks.Stub <IFailureMechanism>();

            mocks.ReplayAll();

            // Call
            using (var properties = new FailureMechanismSectionsProperties(failureMechanism))
            {
                // Assert
                PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
                Assert.AreEqual(2, dynamicProperties.Count);
                const string generalCategoryName = "Algemeen";

                PropertyDescriptor sourcePathProperty = dynamicProperties[0];
                PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sourcePathProperty,
                                                                                generalCategoryName,
                                                                                "Bronlocatie",
                                                                                "De locatie van het bestand waaruit de vakindeling is geïmporteerd.",
                                                                                true);

                PropertyDescriptor sectionsProperty = dynamicProperties[1];
                PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sectionsProperty,
                                                                                generalCategoryName,
                                                                                "Vakindeling",
                                                                                "Vakindeling waarmee de waterkering voor dit faalmechanisme is " +
                                                                                "geschematiseerd ten behoeve van de beoordeling.",
                                                                                true);
                mocks.VerifyAll();
            }
        }
        public void GivenPropertyControlWithData_WhenFailureMechanismUpdated_RefreshRequiredEventRaised()
        {
            // Given
            var failureMechanism = new TestFailureMechanism();

            using (var properties = new FailureMechanismSectionsProperties(failureMechanism))
            {
                var refreshRequiredRaised = 0;
                properties.RefreshRequired += (sender, args) => refreshRequiredRaised++;

                // When
                failureMechanism.NotifyObservers();

                // Then
                Assert.AreEqual(1, refreshRequiredRaised);
            }
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            string sourcePath = TestHelper.GetScratchPadPath();
            IEnumerable <FailureMechanismSection> sections = new[]
            {
                FailureMechanismSectionTestFactory.CreateFailureMechanismSection()
            };

            var failureMechanism = new TestFailureMechanism();

            failureMechanism.SetSections(sections, sourcePath);

            // Call
            using (var properties = new FailureMechanismSectionsProperties(failureMechanism))
            {
                // Assert
                Assert.IsInstanceOf <ObjectProperties <IFailureMechanism> >(properties);
                Assert.IsInstanceOf <IDisposable>(properties);
                Assert.AreSame(failureMechanism, properties.Data);

                TestHelper.AssertTypeConverter <FailureMechanismSectionsProperties, ExpandableArrayConverter>(
                    nameof(FailureMechanismSectionsProperties.Sections));
                Assert.AreEqual(sections.Count(), properties.Sections.Length);

                double sectionStart = 0;
                for (var i = 0; i < sections.Count(); i++)
                {
                    FailureMechanismSection           section  = sections.ElementAt(i);
                    FailureMechanismSectionProperties property = properties.Sections[i];
                    Assert.AreSame(section, property.Data);

                    double sectionEnd = sectionStart + section.Length;
                    Assert.AreEqual(sectionStart, property.SectionStart, property.SectionStart.GetAccuracy());
                    Assert.AreEqual(sectionEnd, property.SectionEnd, property.SectionEnd.GetAccuracy());
                    sectionStart = sectionEnd;
                }

                Assert.AreEqual(sourcePath, properties.SourcePath);
            }
        }