public void Constructor_WithValidParameters_FillsTableWithData() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); using (new AssemblyToolCalculatorFactoryConfig()) { // Call using (var view = new FailureMechanismSectionAssemblyGroupsView(assessmentSection)) { AssemblyGroupsTable <FailureMechanismSectionAssemblyGroup> assemblyGroupsTable = GetAssemblyGroupsTable(view); // Assert IEnumerable <FailureMechanismSectionAssemblyGroupBoundaries> expectedAssemblyGroupBoundaries = FailureMechanismSectionAssemblyGroupsHelper.GetFailureMechanismSectionAssemblyGroupBoundaries(assessmentSection); Assert.AreEqual(expectedAssemblyGroupBoundaries.Count(), assemblyGroupsTable.Rows.Count); for (int i = 0; i < expectedAssemblyGroupBoundaries.Count(); i++) { FailureMechanismSectionAssemblyGroupBoundaries expectedBoundary = expectedAssemblyGroupBoundaries.ElementAt(i); var actualBoundary = (AssemblyGroupRow <FailureMechanismSectionAssemblyGroup>)assemblyGroupsTable.Rows[i].DataBoundItem; Assert.AreEqual(expectedBoundary.FailureMechanismSectionAssemblyGroup, actualBoundary.Group); Assert.AreEqual(expectedBoundary.LowerBoundary, actualBoundary.LowerBoundary); Assert.AreEqual(expectedBoundary.UpperBoundary, actualBoundary.UpperBoundary); } } } }
public void CreateFailureMechanismSectionAssemblyGroupBoundaries_CalculatorRan_ReturnsOutput() { // Setup var random = new Random(11); double signalFloodingProbability = random.NextDouble(); double maximumAllowableFloodingProbability = random.NextDouble(); using (new AssemblyToolCalculatorFactoryConfig()) { var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyGroupBoundariesCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyGroupBoundariesCalculator; // Call FailureMechanismSectionAssemblyGroupBoundaries[] output = FailureMechanismSectionAssemblyGroupBoundariesFactory.CreateFailureMechanismSectionAssemblyGroupBoundaries(signalFloodingProbability, maximumAllowableFloodingProbability) .ToArray(); // Assert FailureMechanismSectionAssemblyGroupBoundaries[] calculatorOutput = calculator.FailureMechanismSectionAssemblyGroupBoundariesOutput.ToArray(); int expectedNrOfOutputs = calculatorOutput.Length; Assert.AreEqual(expectedNrOfOutputs, output.Length); for (var i = 0; i < expectedNrOfOutputs; i++) { FailureMechanismSectionAssemblyGroupBoundaries expectedOutput = calculatorOutput[i]; FailureMechanismSectionAssemblyGroupBoundaries actualOutput = calculatorOutput[i]; Assert.AreEqual(expectedOutput.FailureMechanismSectionAssemblyGroup, actualOutput.FailureMechanismSectionAssemblyGroup); Assert.AreEqual(expectedOutput.LowerBoundary, actualOutput.LowerBoundary); Assert.AreEqual(expectedOutput.UpperBoundary, actualOutput.UpperBoundary); } } }
public void GetFailureMechanismAssemblyGroups_AssemblySucceeds_CorrectlySetsProperties() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); using (new AssemblyToolCalculatorFactoryConfig()) { // Call var properties = new FailureMechanismSectionAssemblyGroupsProperties(assessmentSection); // Assert FailureMechanismSectionAssemblyGroupProperties[] failureMechanismAssemblyGroups = properties.FailureMechanismAssemblyGroups; IEnumerable <FailureMechanismSectionAssemblyGroupBoundaries> output = FailureMechanismSectionAssemblyGroupsHelper.GetFailureMechanismSectionAssemblyGroupBoundaries(assessmentSection); Assert.AreEqual(output.Count(), failureMechanismAssemblyGroups.Length); for (var i = 0; i < output.Count(); i++) { FailureMechanismSectionAssemblyGroupBoundaries assemblyGroupBoundaries = output.ElementAt(i); FailureMechanismSectionAssemblyGroupProperties property = failureMechanismAssemblyGroups[i]; Assert.AreEqual(assemblyGroupBoundaries.FailureMechanismSectionAssemblyGroup, property.Group); Assert.AreEqual(assemblyGroupBoundaries.UpperBoundary, property.UpperBoundary); Assert.AreEqual(assemblyGroupBoundaries.LowerBoundary, property.LowerBoundary); } } }
public void Constructor_WithArguments_ExpectedValues() { // Setup var random = new Random(21); double lowerBoundary = random.NextDouble(); double upperBoundary = random.NextDouble(); var assemblyGroup = random.NextEnumValue <FailureMechanismSectionAssemblyGroup>(); // Call var boundaries = new FailureMechanismSectionAssemblyGroupBoundaries(lowerBoundary, upperBoundary, assemblyGroup); // Assert Assert.IsInstanceOf <AssemblyGroupBoundaries>(boundaries); Assert.AreEqual(lowerBoundary, boundaries.LowerBoundary); Assert.AreEqual(upperBoundary, boundaries.UpperBoundary); }
/// <summary> /// Asserts whether <paramref name="actual"/> is equal to <paramref name="original"/>. /// </summary> /// <param name="original">The original <see cref="CategoriesList{TCategory}"/> with /// <see cref="InterpretationCategory"/>.</param> /// <param name="actual">The actual collection of <see cref="FailureMechanismSectionAssemblyGroupBoundaries"/>.</param> /// <exception cref="AssertionException">Thrown when <paramref name="actual"/> /// is not equal to <paramref name="original"/>.</exception> public static void AssertFailureMechanismSectionAssemblyGroupBoundaries(CategoriesList <InterpretationCategory> original, IEnumerable <FailureMechanismSectionAssemblyGroupBoundaries> actual) { int expectedNrOfCategories = original.Categories.Length; Assert.AreEqual(expectedNrOfCategories, actual.Count()); for (int i = 0; i < expectedNrOfCategories; i++) { InterpretationCategory originalItem = original.Categories.ElementAt(i); FailureMechanismSectionAssemblyGroupBoundaries actualItem = actual.ElementAt(i); Assert.AreEqual(GetFailureMechanismSectionAssemblyGroup(originalItem.Category), actualItem.FailureMechanismSectionAssemblyGroup); ProbabilityAssert.AreEqual(actualItem.LowerBoundary, originalItem.LowerLimit); ProbabilityAssert.AreEqual(actualItem.UpperBoundary, originalItem.UpperLimit); } }
public void GetFailureMechanismSectionAssemblyGroupBoundaries_CalculationSuccessful_ReturnsCorrectAssemblyGroupBoundaries() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); using (new AssemblyToolCalculatorFactoryConfig()) { var calculatorFactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyGroupBoundariesCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyGroupBoundariesCalculator; // Call FailureMechanismSectionAssemblyGroupBoundaries[] assemblyGroupBoundaries = FailureMechanismSectionAssemblyGroupsHelper.GetFailureMechanismSectionAssemblyGroupBoundaries(assessmentSection).ToArray(); // Assert Assert.AreEqual(calculator.FailureMechanismSectionAssemblyGroupBoundariesOutput.Count() + 3, assemblyGroupBoundaries.Length); for (var i = 0; i < calculator.FailureMechanismSectionAssemblyGroupBoundariesOutput.Count(); i++) { FailureMechanismSectionAssemblyGroupBoundaries expectedBoundary = calculator.FailureMechanismSectionAssemblyGroupBoundariesOutput.ElementAt(i); FailureMechanismSectionAssemblyGroupBoundaries actualBoundary = assemblyGroupBoundaries[i]; Assert.AreEqual(expectedBoundary.FailureMechanismSectionAssemblyGroup, actualBoundary.FailureMechanismSectionAssemblyGroup); Assert.AreEqual(expectedBoundary.LowerBoundary, actualBoundary.LowerBoundary); Assert.AreEqual(expectedBoundary.UpperBoundary, actualBoundary.UpperBoundary); } FailureMechanismSectionAssemblyGroupBoundaries dominantGroupBoundaries = assemblyGroupBoundaries[assemblyGroupBoundaries.Length - 3]; Assert.AreEqual(FailureMechanismSectionAssemblyGroup.Dominant, dominantGroupBoundaries.FailureMechanismSectionAssemblyGroup); Assert.AreEqual(double.NaN, dominantGroupBoundaries.UpperBoundary); Assert.AreEqual(double.NaN, dominantGroupBoundaries.LowerBoundary); FailureMechanismSectionAssemblyGroupBoundaries notDominantGroupBoundaries = assemblyGroupBoundaries[assemblyGroupBoundaries.Length - 2]; Assert.AreEqual(FailureMechanismSectionAssemblyGroup.NotDominant, notDominantGroupBoundaries.FailureMechanismSectionAssemblyGroup); Assert.AreEqual(double.NaN, notDominantGroupBoundaries.UpperBoundary); Assert.AreEqual(double.NaN, notDominantGroupBoundaries.LowerBoundary); FailureMechanismSectionAssemblyGroupBoundaries notRelevantGroupBoundaries = assemblyGroupBoundaries[assemblyGroupBoundaries.Length - 1]; Assert.AreEqual(FailureMechanismSectionAssemblyGroup.NotRelevant, notRelevantGroupBoundaries.FailureMechanismSectionAssemblyGroup); Assert.AreEqual(double.NaN, notRelevantGroupBoundaries.UpperBoundary); Assert.AreEqual(double.NaN, notRelevantGroupBoundaries.LowerBoundary); } }
public void Constructor_ValidParameters_ExpectedValues() { // Setup var random = new Random(39); var assemblyCategory = new FailureMechanismSectionAssemblyGroupBoundaries(random.NextDouble(), random.NextDouble(), random.NextEnumValue <FailureMechanismSectionAssemblyGroup>()); // Call var properties = new FailureMechanismSectionAssemblyGroupProperties(assemblyCategory); // Assert Assert.IsInstanceOf <ObjectProperties <FailureMechanismSectionAssemblyGroupBoundaries> >(properties); Assert.AreSame(assemblyCategory, properties.Data); TestHelper.AssertTypeConverter <FailureMechanismSectionAssemblyGroupProperties, ExpandableObjectConverter>(); Assert.AreEqual(assemblyCategory.FailureMechanismSectionAssemblyGroup, properties.Group); Assert.AreEqual(assemblyCategory.LowerBoundary, properties.LowerBoundary); Assert.AreEqual(assemblyCategory.UpperBoundary, properties.UpperBoundary); }
public void Constructor_Always_PropertiesHaveExpectedAttributeValues() { // Setup var random = new Random(39); var assemblyCategory = new FailureMechanismSectionAssemblyGroupBoundaries(random.NextDouble(), random.NextDouble(), random.NextEnumValue <FailureMechanismSectionAssemblyGroup>()); // Call var properties = new FailureMechanismSectionAssemblyGroupProperties(assemblyCategory); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(3, dynamicProperties.Count); const string generalCategoryName = "Algemeen"; PropertyDescriptor nameProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategoryName, "Naam", "Naam van de duidingsklasse.", true); PropertyDescriptor lowerBoundaryProperty = dynamicProperties[1]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lowerBoundaryProperty, generalCategoryName, "Ondergrens [1/jaar]", "Ondergrens van de duidingsklasse.", true); PropertyDescriptor upperBoundaryProperty = dynamicProperties[2]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(upperBoundaryProperty, generalCategoryName, "Bovengrens [1/jaar]", "Bovengrens van de duidingsklasse.", true); }