public void Constructor_WithAssemblyGroupSet_ExpectedColumnStates(FailureMechanismSectionAssemblyGroup assemblyGroup,
                                                                          Color expectedBackgroundColor)
        {
            // Setup
            var random = new Random(21);

            var mocks         = new MockRepository();
            var errorProvider = mocks.Stub <IFailureMechanismSectionResultRowErrorProvider>();

            mocks.ReplayAll();

            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var result = new NonAdoptableFailureMechanismSectionResult(section);

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance;
                FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
                calculator.FailureMechanismSectionAssemblyResultOutput = new FailureMechanismSectionAssemblyResultWrapper(
                    new FailureMechanismSectionAssemblyResult(double.NaN, double.NaN, double.NaN, assemblyGroup),
                    random.NextEnumValue <AssemblyMethod>(), random.NextEnumValue <AssemblyMethod>());

                // Call
                var row = new NonAdoptableFailureMechanismSectionResultRow(result, errorProvider, new AssessmentSectionStub(), ConstructionProperties);

                // Assert
                IDictionary <int, DataGridViewColumnStateDefinition> columnStateDefinitions = row.ColumnStateDefinitions;

                DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(
                    columnStateDefinitions[ConstructionProperties.AssemblyGroupIndex], expectedBackgroundColor);
            }

            mocks.VerifyAll();
        }
Пример #2
0
        public void Constructor_WithAssemblyGroupSet_ExpectedColumnStates(FailureMechanismSectionAssemblyGroup assemblyGroup,
                                                                          Color expectedBackgroundColor)
        {
            // Setup
            var mocks         = new MockRepository();
            var errorProvider = mocks.Stub <IFailureMechanismSectionResultRowErrorProvider>();

            mocks.ReplayAll();

            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
            var result = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResult(section);

            Func <FailureMechanismSectionAssemblyResultWrapper> performAssemblyFunc = () => new FailureMechanismSectionAssemblyResultWrapper(
                FailureMechanismSectionAssemblyResultTestFactory.CreateFailureMechanismSectionAssemblyResult(assemblyGroup),
                AssemblyMethod.BOI0A1, AssemblyMethod.BOI0B1);

            // Call
            var row = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResultRow(result, errorProvider, performAssemblyFunc, ConstructionProperties);

            // Assert
            IDictionary <int, DataGridViewColumnStateDefinition> columnStateDefinitions = row.ColumnStateDefinitions;

            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(
                columnStateDefinitions[ConstructionProperties.AssemblyGroupIndex], expectedBackgroundColor);

            mocks.VerifyAll();
        }
        /// <summary>
        /// Asserts whether <paramref name="actual"/> is equal to
        /// <paramref name="failureMechanismResults"/> and <paramref name="combinedResults"/>.
        /// </summary>
        /// <param name="failureMechanismResults">The original <see cref="IEnumerable{T}"/> of <see cref="FailureMechanismSectionList"/>.</param>
        /// <param name="combinedResults">The original <see cref="IEnumerable{T}"/> of <see cref="FailureMechanismSectionWithCategory"/>.</param>
        /// <param name="actual">The actual collection of <see cref="CombinedFailureMechanismSectionAssembly"/>.</param>
        /// <exception cref="AssertionException">Thrown when <paramref name="actual"/> is not equal to
        /// <paramref name="failureMechanismResults"/> and <paramref name="combinedResults"/>.</exception>
        public static void AssertAssembly(IEnumerable <FailureMechanismSectionList> failureMechanismResults,
                                          IEnumerable <FailureMechanismSectionWithCategory> combinedResults,
                                          IEnumerable <CombinedFailureMechanismSectionAssembly> actual)
        {
            Assert.AreEqual(combinedResults.Count(), actual.Count());
            for (var i = 0; i < combinedResults.Count(); i++)
            {
                FailureMechanismSectionWithCategory     combinedResult = combinedResults.ElementAt(i);
                CombinedFailureMechanismSectionAssembly actualCombinedFailureMechanismSectionAssembly = actual.ElementAt(i);

                Assert.AreEqual(combinedResult.Start, actualCombinedFailureMechanismSectionAssembly.Section.SectionStart);
                Assert.AreEqual(combinedResult.End, actualCombinedFailureMechanismSectionAssembly.Section.SectionEnd);
                Assert.AreEqual(FailureMechanismSectionAssemblyGroupConverter.ConvertTo(combinedResult.Category),
                                actualCombinedFailureMechanismSectionAssembly.Section.FailureMechanismSectionAssemblyGroup);

                Assert.AreEqual(failureMechanismResults.Count(), actualCombinedFailureMechanismSectionAssembly.FailureMechanismSectionAssemblyGroupResults.Count());

                for (var j = 0; j < failureMechanismResults.Count(); j++)
                {
                    FailureMechanismSectionAssemblyGroup expectedGroup = FailureMechanismSectionAssemblyGroupConverter.ConvertTo(
                        ((FailureMechanismSectionWithCategory)failureMechanismResults.ElementAt(j).Sections.ElementAt(i)).Category);
                    Assert.AreEqual(expectedGroup, actualCombinedFailureMechanismSectionAssembly.FailureMechanismSectionAssemblyGroupResults.ElementAt(j));
                }
            }
        }
        public void ConvertTo_ValidInterpretationCategory_ReturnsExpectedValue(EInterpretationCategory interpretationCategory, FailureMechanismSectionAssemblyGroup expectedAssemblyGroup)
        {
            // Call
            FailureMechanismSectionAssemblyGroup convertedAssemblyGroup = FailureMechanismSectionAssemblyGroupConverter.ConvertTo(interpretationCategory);

            // Assert
            Assert.AreEqual(expectedAssemblyGroup, convertedAssemblyGroup);
        }
Пример #5
0
 private static ExportableFailureMechanismCombinedSectionAssemblyResult CreateExportableFailureMechanismCombinedSectionAssemblyResult(
     FailureMechanismSectionAssemblyGroup sectionAssemblyGroup, AssemblyMethod assemblyMethod,
     ExportableFailureMechanismType failureMechanismType, string failureMechanismCode, string failureMechanismName)
 {
     return(new ExportableFailureMechanismCombinedSectionAssemblyResult(
                new ExportableFailureMechanismSubSectionAssemblyResult(sectionAssemblyGroup, ExportableAssemblyMethodFactory.Create(assemblyMethod)),
                failureMechanismType, failureMechanismCode, failureMechanismName));
 }
Пример #6
0
 /// <summary>
 /// Creates a new instance of <see cref="FailureMechanismSectionAssemblyResult"/>.
 /// </summary>
 /// <param name="profileProbability">The probability of the failure mechanism section, expressed for profile.</param>
 /// <param name="sectionProbability">The probability of the failure mechanism section, expressed for the section.</param>
 /// <param name="n">The length effect of the failure mechanism section.</param>
 /// <param name="failureMechanismSectionAssemblyGroup">The <see cref="Data.FailureMechanismSectionAssemblyGroup"/>.</param>
 public FailureMechanismSectionAssemblyResult(double profileProbability, double sectionProbability, double n,
                                              FailureMechanismSectionAssemblyGroup failureMechanismSectionAssemblyGroup)
 {
     ProfileProbability = profileProbability;
     SectionProbability = sectionProbability;
     N = n;
     FailureMechanismSectionAssemblyGroup = failureMechanismSectionAssemblyGroup;
 }
        private static CombinedAssemblyFailureMechanismSection CreateSection <TFailureMechanismSectionResult>(
            TFailureMechanismSectionResult sectionResult, FailureMechanismSectionAssemblyGroup assemblyGroup, double sectionStart)
            where TFailureMechanismSectionResult : FailureMechanismSectionResult
        {
            double sectionEnd = sectionResult.Section.Length + sectionStart;

            return(new CombinedAssemblyFailureMechanismSection(sectionStart, sectionEnd, assemblyGroup));
        }
        public void ConvertFrom_ValidAssemblyGroup_ReturnsExpectedValue(FailureMechanismSectionAssemblyGroup assemblyGroup, EInterpretationCategory expectedInterpretationCategory)
        {
            // Call
            EInterpretationCategory convertedInterpretationCategory = FailureMechanismSectionAssemblyGroupConverter.ConvertFrom(assemblyGroup);

            // Assert
            Assert.AreEqual(expectedInterpretationCategory, convertedInterpretationCategory);
        }
        public void GetFailureMechanismSectionAssemblyGroupColor_ValidFailureMechanismSectionAssemblyGroup_ReturnsExpectedColor(
            FailureMechanismSectionAssemblyGroup assemblyGroup, Color expectedColor)
        {
            // Call
            Color color = FailureMechanismSectionAssemblyGroupColorHelper.GetFailureMechanismSectionAssemblyGroupColor(assemblyGroup);

            // Assert
            Assert.AreEqual(expectedColor, color);
        }
Пример #10
0
        public void Create_WithFailureMechanismSectionCategoryGroup_ReturnsExpectedValues(
            FailureMechanismSectionAssemblyGroup assemblyGroup, SerializableFailureMechanismSectionAssemblyGroup expectedSerializableAssemblyGroup)
        {
            // Call
            SerializableFailureMechanismSectionAssemblyGroup serializableGroup = SerializableFailureMechanismSectionAssemblyGroupCreator.Create(assemblyGroup);

            // Assert
            Assert.AreEqual(expectedSerializableAssemblyGroup, serializableGroup);
        }
Пример #11
0
        public void Create_NotSupportedFailureMechanismSectionAssemblyGroup_ThrowsNotSupportedException(
            FailureMechanismSectionAssemblyGroup assemblyGroup)
        {
            // Call
            void Call() => SerializableFailureMechanismSectionAssemblyGroupCreator.Create(assemblyGroup);

            // Assert
            Assert.Throws <NotSupportedException>(Call);
        }
 /// <summary>
 /// Creates a new instance of <see cref="ExportableFailureMechanismSectionAssemblyResult"/>.
 /// </summary>
 /// <param name="failureMechanismSection">The failure mechanism section.</param>
 /// <param name="assemblyGroup">The assembly group of this section.</param>
 /// <param name="probability">The probability of this section.</param>
 /// <param name="assemblyGroupAssemblyMethod">The method used to assemble the assembly group for this section.</param>
 /// <param name="probabilityAssemblyMethod">The method used to assemble the probability for this section.</param>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanismSection"/> is <c>null</c>.</exception>
 public ExportableFailureMechanismSectionAssemblyWithProbabilityResult(ExportableFailureMechanismSection failureMechanismSection,
                                                                       FailureMechanismSectionAssemblyGroup assemblyGroup,
                                                                       double probability,
                                                                       ExportableAssemblyMethod assemblyGroupAssemblyMethod,
                                                                       ExportableAssemblyMethod probabilityAssemblyMethod)
     : base(failureMechanismSection, assemblyGroup, assemblyGroupAssemblyMethod)
 {
     Probability = probability;
     ProbabilityAssemblyMethod = probabilityAssemblyMethod;
 }
        private static void AssertSectionsWithResult(IEnumerable <FailureMechanismSectionResult> originalSectionResults,
                                                     FailureMechanismSectionAssemblyGroup expectedAssemblyGroupInput,
                                                     IEnumerable <CombinedAssemblyFailureMechanismSection> inputSections)
        {
            AssertSections(originalSectionResults, inputSections);

            for (var i = 0; i < originalSectionResults.Count(); i++)
            {
                Assert.AreEqual(expectedAssemblyGroupInput, inputSections.ElementAt(i).FailureMechanismSectionAssemblyGroup);
            }
        }
Пример #14
0
        private static LineCategoryTheme CreateAssemblyGroupTheme(Color color, FailureMechanismSectionAssemblyGroup assemblyGroup)
        {
            var lineStyle = new LineStyle
            {
                Color     = color,
                DashStyle = lineDashStyle,
                Width     = lineWidth
            };

            return(new LineCategoryTheme(CreateCriterion(assemblyGroup), lineStyle));
        }
Пример #15
0
        /// <summary>
        /// Helper method that sets the style of a <paramref name="columnStateDefinition"/> based on a
        /// <see cref="FailureMechanismSectionAssemblyGroup"/>.
        /// </summary>
        /// <param name="columnStateDefinition">The column state definition to set the style for.</param>
        /// <param name="assemblyGroup">The assembly group to base the style on.</param>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="assemblyGroup"/>
        /// has an invalid value for <see cref="FailureMechanismSectionAssemblyGroup"/>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="assemblyGroup"/>
        /// is not supported.</exception>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="columnStateDefinition"/>
        /// is <c>null</c>.</exception>
        public static void SetAssemblyGroupStyle(DataGridViewColumnStateDefinition columnStateDefinition,
                                                 FailureMechanismSectionAssemblyGroup assemblyGroup)
        {
            if (columnStateDefinition == null)
            {
                throw new ArgumentNullException(nameof(columnStateDefinition));
            }

            columnStateDefinition.Style = new CellStyle(
                Color.FromKnownColor(KnownColor.ControlText),
                FailureMechanismSectionAssemblyGroupColorHelper.GetFailureMechanismSectionAssemblyGroupColor(assemblyGroup));
        }
        /// <summary>
        /// Creates a new instance of <see cref="ExportableFailureMechanismSectionAssemblyResult"/>.
        /// </summary>
        /// <param name="failureMechanismSection">The failure mechanism section.</param>
        /// <param name="assemblyGroup">The assembly group of this section.</param>
        /// <param name="assemblyGroupAssemblyMethod">The method used to assemble the assembly group for this section.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanismSection"/> is <c>null</c>.</exception>
        public ExportableFailureMechanismSectionAssemblyResult(ExportableFailureMechanismSection failureMechanismSection,
                                                               FailureMechanismSectionAssemblyGroup assemblyGroup,
                                                               ExportableAssemblyMethod assemblyGroupAssemblyMethod)
        {
            if (failureMechanismSection == null)
            {
                throw new ArgumentNullException(nameof(failureMechanismSection));
            }

            FailureMechanismSection     = failureMechanismSection;
            AssemblyGroup               = assemblyGroup;
            AssemblyGroupAssemblyMethod = assemblyGroupAssemblyMethod;
        }
Пример #17
0
        public void Create_InvalidFailureMechanismSectionAssemblyGroup_ThrowInvalidEnumArgumentException()
        {
            // Setup
            const FailureMechanismSectionAssemblyGroup assemblyGroup = (FailureMechanismSectionAssemblyGroup)999;

            // Call
            void Call() => SerializableFailureMechanismSectionAssemblyGroupCreator.Create(assemblyGroup);

            // Assert
            var message = $"The value of argument 'assemblyGroup' ({assemblyGroup}) is invalid for Enum type '{nameof(FailureMechanismSectionAssemblyGroup)}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, message);
        }
        public void SetAssemblyGroupStyle_ValidFailureMechanismSectionAssemblyGroup_UpdatesColumnStyle(
            FailureMechanismSectionAssemblyGroup assemblyGroup, Color expectedColor)
        {
            // Setup
            var columnStateDefinition = new DataGridViewColumnStateDefinition();

            // Call
            FailureMechanismSectionResultRowHelper.SetAssemblyGroupStyle(columnStateDefinition, assemblyGroup);

            // Assert
            Assert.AreEqual(expectedColor, columnStateDefinition.Style.BackgroundColor);
            Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), columnStateDefinition.Style.TextColor);
        }
        public void ConvertFrom_InvalidAssemblyGroup_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            const FailureMechanismSectionAssemblyGroup assemblyGroup = (FailureMechanismSectionAssemblyGroup)99;

            // Call
            void Call() => FailureMechanismSectionAssemblyGroupConverter.ConvertFrom(assemblyGroup);

            // Assert
            var expectedMessage = $"The value of argument 'assemblyGroup' ({assemblyGroup}) is invalid for Enum type '{nameof(FailureMechanismSectionAssemblyGroup)}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, expectedMessage);
        }
        public void SetAssemblyGroupStyle_InvalidFailureMechanismSectionAssemblyGroup_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            var columnStateDefinition = new DataGridViewColumnStateDefinition();
            const FailureMechanismSectionAssemblyGroup assemblyGroup = (FailureMechanismSectionAssemblyGroup)99;

            // Call
            void Call() => FailureMechanismSectionResultRowHelper.SetAssemblyGroupStyle(columnStateDefinition, assemblyGroup);

            // Assert
            var expectedMessage = $"The value of argument 'assemblyGroup' ({assemblyGroup}) is invalid for Enum type '{nameof(FailureMechanismSectionAssemblyGroup)}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, expectedMessage);
        }
Пример #21
0
        /// <summary>
        /// Gets the color for a failure mechanism section assembly group.
        /// </summary>
        /// <param name="assemblyGroup">The assembly group to get the color for.</param>
        /// <returns>The <see cref="Color"/> corresponding to the given assembly group.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="assemblyGroup"/>
        /// has an invalid value for <see cref="FailureMechanismSectionAssemblyGroup"/>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="assemblyGroup"/>
        /// is not supported.</exception>
        public static Color GetFailureMechanismSectionAssemblyGroupColor(FailureMechanismSectionAssemblyGroup assemblyGroup)
        {
            if (!Enum.IsDefined(typeof(FailureMechanismSectionAssemblyGroup), assemblyGroup))
            {
                throw new InvalidEnumArgumentException(nameof(assemblyGroup),
                                                       (int)assemblyGroup,
                                                       typeof(FailureMechanismSectionAssemblyGroup));
            }

            switch (assemblyGroup)
            {
            case FailureMechanismSectionAssemblyGroup.NotDominant:
                return(Color.FromArgb(192, 192, 192));

            case FailureMechanismSectionAssemblyGroup.III:
                return(Color.FromArgb(34, 139, 34));

            case FailureMechanismSectionAssemblyGroup.II:
                return(Color.FromArgb(146, 208, 80));

            case FailureMechanismSectionAssemblyGroup.I:
                return(Color.FromArgb(198, 224, 180));

            case FailureMechanismSectionAssemblyGroup.Zero:
                return(Color.FromArgb(255, 255, 0));

            case FailureMechanismSectionAssemblyGroup.IMin:
                return(Color.FromArgb(255, 165, 0));

            case FailureMechanismSectionAssemblyGroup.IIMin:
                return(Color.FromArgb(255, 0, 0));

            case FailureMechanismSectionAssemblyGroup.IIIMin:
                return(Color.FromArgb(178, 34, 34));

            case FailureMechanismSectionAssemblyGroup.Dominant:
                return(Color.FromArgb(255, 90, 172));

            case FailureMechanismSectionAssemblyGroup.NoResult:
                return(Color.FromArgb(255, 255, 255));

            case FailureMechanismSectionAssemblyGroup.NotRelevant:
                return(Color.FromArgb(38, 245, 245));

            default:
                throw new NotSupportedException();
            }
        }
Пример #22
0
        /// <summary>
        /// Converts a <see cref="FailureMechanismSectionAssemblyGroup"/> into an <see cref="EInterpretationCategory"/>.
        /// </summary>
        /// <param name="assemblyGroup">The <see cref="FailureMechanismSectionAssemblyGroup"/> to convert.</param>
        /// <returns>A <see cref="EInterpretationCategory"/> based on <paramref name="assemblyGroup"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="assemblyGroup"/>
        /// is an invalid value.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="assemblyGroup"/>
        /// is a valid value, but unsupported.</exception>
        public static EInterpretationCategory ConvertFrom(FailureMechanismSectionAssemblyGroup assemblyGroup)
        {
            if (!Enum.IsDefined(typeof(FailureMechanismSectionAssemblyGroup), assemblyGroup))
            {
                throw new InvalidEnumArgumentException(nameof(assemblyGroup),
                                                       (int)assemblyGroup,
                                                       typeof(FailureMechanismSectionAssemblyGroup));
            }

            switch (assemblyGroup)
            {
            case FailureMechanismSectionAssemblyGroup.NotDominant:
                return(EInterpretationCategory.NotDominant);

            case FailureMechanismSectionAssemblyGroup.III:
                return(EInterpretationCategory.III);

            case FailureMechanismSectionAssemblyGroup.II:
                return(EInterpretationCategory.II);

            case FailureMechanismSectionAssemblyGroup.I:
                return(EInterpretationCategory.I);

            case FailureMechanismSectionAssemblyGroup.Zero:
                return(EInterpretationCategory.Zero);

            case FailureMechanismSectionAssemblyGroup.IMin:
                return(EInterpretationCategory.IMin);

            case FailureMechanismSectionAssemblyGroup.IIMin:
                return(EInterpretationCategory.IIMin);

            case FailureMechanismSectionAssemblyGroup.IIIMin:
                return(EInterpretationCategory.IIIMin);

            case FailureMechanismSectionAssemblyGroup.Dominant:
                return(EInterpretationCategory.Dominant);

            case FailureMechanismSectionAssemblyGroup.NoResult:
                return(EInterpretationCategory.NoResult);

            case FailureMechanismSectionAssemblyGroup.NotRelevant:
                return(EInterpretationCategory.NotRelevant);

            default:
                throw new NotSupportedException();
            }
        }
Пример #23
0
        /// <summary>
        /// Creates a <see cref="SerializableFailureMechanismSectionAssemblyGroup"/> based on <paramref name="assemblyGroup"/>.
        /// </summary>
        /// <param name="assemblyGroup">The <see cref="FailureMechanismSectionAssemblyGroup"/> to
        /// create a <see cref="SerializableFailureMechanismSectionAssemblyGroup"/> for.</param>
        /// <returns>A <see cref="SerializableFailureMechanismSectionAssemblyGroup"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="assemblyGroup"/>
        /// is an invalid value.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="assemblyGroup"/>
        /// is a valid value, but unsupported.</exception>
        public static SerializableFailureMechanismSectionAssemblyGroup Create(FailureMechanismSectionAssemblyGroup assemblyGroup)
        {
            if (!Enum.IsDefined(typeof(FailureMechanismSectionAssemblyGroup), assemblyGroup))
            {
                throw new InvalidEnumArgumentException(nameof(assemblyGroup),
                                                       (int)assemblyGroup,
                                                       typeof(FailureMechanismSectionAssemblyGroup));
            }

            switch (assemblyGroup)
            {
            case FailureMechanismSectionAssemblyGroup.NotDominant:
                return(SerializableFailureMechanismSectionAssemblyGroup.NotDominant);

            case FailureMechanismSectionAssemblyGroup.III:
                return(SerializableFailureMechanismSectionAssemblyGroup.III);

            case FailureMechanismSectionAssemblyGroup.II:
                return(SerializableFailureMechanismSectionAssemblyGroup.II);

            case FailureMechanismSectionAssemblyGroup.I:
                return(SerializableFailureMechanismSectionAssemblyGroup.I);

            case FailureMechanismSectionAssemblyGroup.Zero:
                return(SerializableFailureMechanismSectionAssemblyGroup.Zero);

            case FailureMechanismSectionAssemblyGroup.IMin:
                return(SerializableFailureMechanismSectionAssemblyGroup.IMin);

            case FailureMechanismSectionAssemblyGroup.IIMin:
                return(SerializableFailureMechanismSectionAssemblyGroup.IIMin);

            case FailureMechanismSectionAssemblyGroup.IIIMin:
                return(SerializableFailureMechanismSectionAssemblyGroup.IIIMin);

            case FailureMechanismSectionAssemblyGroup.NotRelevant:
                return(SerializableFailureMechanismSectionAssemblyGroup.NotRelevant);

            default:
                throw new NotSupportedException();
            }
        }
Пример #24
0
        /// <summary>
        /// Creates a new instance of <see cref="CombinedFailureMechanismSectionAssemblyResult"/>.
        /// </summary>
        /// <param name="sectionStart">The start of the section from the beginning of the reference line
        /// in meters.</param>
        /// <param name="sectionEnd">The end of the section from the beginning of the reference line
        /// in meters.</param>
        /// <param name="totalResult">The total result of the section.</param>
        /// <param name="commonSectionAssemblyMethod">The <see cref="AssemblyMethod"/>
        /// that is used to get the common sections.</param>
        /// <param name="failureMechanismResultsAssemblyMethod">The <see cref="AssemblyMethod"/>
        /// that is used to assemble the failure mechanism results.</param>
        /// <param name="combinedSectionResultAssemblyMethod">The <see cref="AssemblyMethod"/>
        /// that is used to assemble the combined section results.</param>
        /// <param name="properties">The container of the properties for the
        /// <see cref="CombinedFailureMechanismSectionAssemblyResult"/>.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="properties"/>
        /// is <c>null</c>.</exception>
        public CombinedFailureMechanismSectionAssemblyResult(double sectionStart, double sectionEnd,
                                                             FailureMechanismSectionAssemblyGroup totalResult,
                                                             AssemblyMethod commonSectionAssemblyMethod,
                                                             AssemblyMethod failureMechanismResultsAssemblyMethod,
                                                             AssemblyMethod combinedSectionResultAssemblyMethod,
                                                             ConstructionProperties properties)
        {
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            SectionStart              = sectionStart;
            SectionEnd                = sectionEnd;
            Piping                    = properties.Piping;
            GrassCoverErosionInwards  = properties.GrassCoverErosionInwards;
            MacroStabilityInwards     = properties.MacroStabilityInwards;
            Microstability            = properties.Microstability;
            StabilityStoneCover       = properties.StabilityStoneCover;
            WaveImpactAsphaltCover    = properties.WaveImpactAsphaltCover;
            WaterPressureAsphaltCover = properties.WaterPressureAsphaltCover;
            GrassCoverErosionOutwards = properties.GrassCoverErosionOutwards;
            GrassCoverSlipOffOutwards = properties.GrassCoverSlipOffOutwards;
            GrassCoverSlipOffInwards  = properties.GrassCoverSlipOffInwards;
            HeightStructures          = properties.HeightStructures;
            ClosingStructures         = properties.ClosingStructures;
            PipingStructure           = properties.PipingStructure;
            StabilityPointStructures  = properties.StabilityPointStructures;
            DuneErosion               = properties.DuneErosion;
            SpecificFailureMechanisms = properties.SpecificFailureMechanisms;
            TotalResult               = totalResult;

            CommonSectionAssemblyMethod           = commonSectionAssemblyMethod;
            FailureMechanismResultsAssemblyMethod = failureMechanismResultsAssemblyMethod;
            CombinedSectionResultAssemblyMethod   = combinedSectionResultAssemblyMethod;
        }
Пример #25
0
 /// <summary>
 /// Creates a new instance of <see cref="CombinedAssemblyFailureMechanismSection"/>.
 /// </summary>
 /// <param name="sectionStart">The start of the section from the beginning of the reference line in meters.</param>
 /// <param name="sectionEnd">The end of the section from the beginning of the reference line in meters.</param>
 /// <param name="failureMechanismSectionAssemblyGroup">The failure mechanism section assembly group.</param>
 public CombinedAssemblyFailureMechanismSection(double sectionStart, double sectionEnd, FailureMechanismSectionAssemblyGroup failureMechanismSectionAssemblyGroup)
 {
     SectionStart = sectionStart;
     SectionEnd   = sectionEnd;
     FailureMechanismSectionAssemblyGroup = failureMechanismSectionAssemblyGroup;
 }
 /// <summary>
 /// Creates a new instance of <see cref="ExportableFailureMechanismSubSectionAssemblyResult"/>.
 /// </summary>
 /// <param name="assemblyMethod">The method that was used to assemble this result.</param>
 /// <param name="assemblyGroup">The assembly group of this section.</param>
 public ExportableFailureMechanismSubSectionAssemblyResult(FailureMechanismSectionAssemblyGroup assemblyGroup,
                                                           ExportableAssemblyMethod assemblyMethod)
 {
     AssemblyMethod = assemblyMethod;
     AssemblyGroup  = assemblyGroup;
 }
Пример #27
0
        public void Create_SectionResultHasInvalidAssemblyGroup_ThrowsAssemblyCreatorException(FailureMechanismSectionAssemblyGroup assemblyGroup)
        {
            // Setup
            var random        = new Random(21);
            var sectionResult = new ExportableFailureMechanismSectionAssemblyWithProbabilityResult(
                ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(),
                assemblyGroup, random.NextDouble(), random.NextEnumValue <ExportableAssemblyMethod>(),
                random.NextEnumValue <ExportableAssemblyMethod>());

            // Call
            void Call() => SerializableFailureMechanismSectionAssemblyResultCreator.Create(sectionResult);

            // Assert
            var exception = Assert.Throws <AssemblyCreatorException>(Call);

            Assert.AreEqual("The assembly result is invalid and cannot be created.", exception.Message);
        }
        public void Constructor_WithCombinedFailureMechanismAssemblyResultContainingOnlyFailureMechanismsInAssembly_ExpectedColumnStates(
            FailureMechanismSectionAssemblyGroup assemblyGroup,
            Color expectedBackgroundColor)
        {
            // Setup
            var random = new Random(21);

            var result = new CombinedFailureMechanismSectionAssemblyResult(random.NextDouble(), random.NextDouble(), assemblyGroup, random.NextEnumValue <AssemblyMethod>(),
                                                                           random.NextEnumValue <AssemblyMethod>(), random.NextEnumValue <AssemblyMethod>(),
                                                                           new CombinedFailureMechanismSectionAssemblyResult.ConstructionProperties
            {
                Piping = assemblyGroup,
                GrassCoverErosionInwards  = assemblyGroup,
                MacroStabilityInwards     = assemblyGroup,
                Microstability            = assemblyGroup,
                StabilityStoneCover       = assemblyGroup,
                WaveImpactAsphaltCover    = assemblyGroup,
                WaterPressureAsphaltCover = assemblyGroup,
                GrassCoverErosionOutwards = assemblyGroup,
                GrassCoverSlipOffOutwards = assemblyGroup,
                GrassCoverSlipOffInwards  = assemblyGroup,
                HeightStructures          = assemblyGroup,
                ClosingStructures         = assemblyGroup,
                PipingStructure           = assemblyGroup,
                StabilityPointStructures  = assemblyGroup,
                DuneErosion = assemblyGroup,
                SpecificFailureMechanisms = new FailureMechanismSectionAssemblyGroup?[]
                {
                    assemblyGroup,
                    assemblyGroup
                }
            });

            // Call
            var row = new CombinedFailureMechanismSectionAssemblyResultRow(result);

            // Assert
            IDictionary <int, DataGridViewColumnStateDefinition> columnStateDefinitions = row.ColumnStateDefinitions;

            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[pipingIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[grassCoverErosionInwardsIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[macroStabilityInwardsIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[microstabililityIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[stabilityStoneCoverIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[waveImpactAsphaltCoverIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[waterPressureAsphaltCoverIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[grassCoverErosionOutwardsIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[grassCoverSlipOffOutwardsIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[grassCoverSlipOffInwardsIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[heightStructuresIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[closingStructuresIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[pipingStructureIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[stabilityPointStructuresIndex], expectedBackgroundColor);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[duneErosionIndex], expectedBackgroundColor);

            for (var i = 0; i < result.SpecificFailureMechanisms.Length; i++)
            {
                DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[specificFailureMechanismStartIndex + i], expectedBackgroundColor);
            }

            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnWithColorState(columnStateDefinitions[specificFailureMechanismStartIndex + result.SpecificFailureMechanisms.Length], expectedBackgroundColor);
        }
Пример #29
0
 private static CellStyle CreateCellStyle(FailureMechanismSectionAssemblyGroup failureMechanismSectionAssemblyGroup)
 {
     return(new CellStyle(Color.FromKnownColor(KnownColor.ControlText),
                          FailureMechanismSectionAssemblyGroupColorHelper.GetFailureMechanismSectionAssemblyGroupColor(failureMechanismSectionAssemblyGroup)));
 }
 /// <summary>
 /// Creates a configured <see cref="FailureMechanismSectionAssemblyResult"/> with an user defined <see cref="FailureMechanismSectionAssemblyGroup"/>.
 /// </summary>
 /// <param name="assemblyGroup">The <see cref="FailureMechanismSectionAssemblyGroup"/> of the result.</param>
 /// <returns>A <see cref="FailureMechanismSectionAssemblyResult"/>.</returns>
 public static FailureMechanismSectionAssemblyResult CreateFailureMechanismSectionAssemblyResult(FailureMechanismSectionAssemblyGroup assemblyGroup)
 {
     return(new FailureMechanismSectionAssemblyResult(double.NaN, double.NaN, double.NaN, assemblyGroup));
 }