public void GetProperties_ValidData_ReturnsExpectedValues() { // Setup var random = new Random(39); const long id = 1234L; const double x = 567.0; const double y = 890.0; const string name = "<some name>"; double result = random.NextDouble(); var calculationConvergence = random.NextEnumValue <CalculationConvergence>(); var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(id, name, x, y)) { Output = new TestHydraulicBoundaryLocationCalculationOutput(result, calculationConvergence) }; // Call var properties = new TestHydraulicBoundaryLocationCalculationProperties(hydraulicBoundaryLocationCalculation); // Assert Assert.AreEqual(id, properties.Id); Assert.AreEqual(name, properties.Name); var coordinates = new Point2D(x, y); Assert.AreEqual(coordinates, properties.Location); Assert.AreEqual(result, properties.Result, properties.Result.GetAccuracy()); Assert.AreEqual(calculationConvergence, properties.Convergence); }
public void Constructor_ExpectedProperties() { // Setup var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()); // Call var properties = new TestHydraulicBoundaryLocationCalculationProperties(hydraulicBoundaryLocationCalculation); // Assert Assert.IsInstanceOf <HydraulicBoundaryLocationCalculationBaseProperties>(properties); Assert.AreSame(hydraulicBoundaryLocationCalculation, properties.Data); }
public void ToString_Always_ReturnsNameAndLocation() { // Setup const string name = "test"; const long id = 1234L; const double x = 567.0; const double y = 890.0; var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(id, name, x, y); var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation); // Call HydraulicBoundaryLocationCalculationProperties properties = new TestHydraulicBoundaryLocationCalculationProperties(hydraulicBoundaryLocationCalculation); // Assert string expectedString = $"{name} {new Point2D(x, y)}"; Assert.AreEqual(expectedString, properties.ToString()); }
public void Constructor_WithoutGeneralIllustrationPointsResult_PropertiesHaveExpectedAttributesValues() { // Setup var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()); // Call var properties = new TestHydraulicBoundaryLocationCalculationProperties(hydraulicBoundaryLocationCalculation); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(10, dynamicProperties.Count); const string generalCategory = "Algemeen"; const string resultCategory = "Resultaat"; const string illustrationPointsCategory = "Illustratiepunten"; PropertyDescriptor idProperty = dynamicProperties[idPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(idProperty, generalCategory, "ID", "ID van de hydraulische belastingenlocatie in de database.", true); PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategory, "Naam", "Naam van de hydraulische belastingenlocatie.", true); PropertyDescriptor coordinatesProperty = dynamicProperties[coordinatesPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(coordinatesProperty, generalCategory, "Coördinaten [m]", "Coördinaten van de hydraulische belastingenlocatie.", true); PropertyDescriptor resultProperty = dynamicProperties[resultPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(resultProperty, resultCategory, nameof(properties.Result), "", true); PropertyDescriptor targetProbabilityProperty = dynamicProperties[targetProbabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetProbabilityProperty, resultCategory, "Doelkans [1/jaar]", "De ingevoerde kans waarvoor het resultaat moet worden berekend.", true); PropertyDescriptor targetReliabilityProperty = dynamicProperties[targetReliabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetReliabilityProperty, resultCategory, "Betrouwbaarheidsindex doelkans [-]", "Betrouwbaarheidsindex van de ingevoerde kans waarvoor het resultaat moet worden berekend.", true); PropertyDescriptor calculatedProbabilityProperty = dynamicProperties[calculatedProbabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculatedProbabilityProperty, resultCategory, "Berekende kans [1/jaar]", "De berekende kans van voorkomen van het berekende resultaat.", true); PropertyDescriptor calculatedReliabilityProperty = dynamicProperties[calculatedReliabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculatedReliabilityProperty, resultCategory, "Betrouwbaarheidsindex berekende kans [-]", "Betrouwbaarheidsindex van de berekende kans van voorkomen van het berekende resultaat.", true); PropertyDescriptor convergenceProperty = dynamicProperties[convergencePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(convergenceProperty, resultCategory, "Convergentie", string.Empty, true); PropertyDescriptor calculateIllustrationPointsProperty = dynamicProperties[shouldCalculateIllustrationPointsIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculateIllustrationPointsProperty, illustrationPointsCategory, "Illustratiepunten inlezen", "Neem de informatie over de illustratiepunten op in het berekeningsresultaat."); }
public void Constructor_WithGeneralIllustrationPointsResult_PropertiesHaveExpectedAttributesValues() { // Setup var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()) { Output = new TestHydraulicBoundaryLocationCalculationOutput(new TestGeneralResultSubMechanismIllustrationPoint()) }; // Call var properties = new TestHydraulicBoundaryLocationCalculationProperties(hydraulicBoundaryLocationCalculation); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(14, dynamicProperties.Count); const string generalCategory = "Algemeen"; const string resultCategory = "Resultaat"; const string illustrationPointsCategory = "Illustratiepunten"; PropertyDescriptor idProperty = dynamicProperties[idPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(idProperty, generalCategory, "ID", "ID van de hydraulische belastingenlocatie in de database.", true); PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategory, "Naam", "Naam van de hydraulische belastingenlocatie.", true); PropertyDescriptor coordinatesProperty = dynamicProperties[coordinatesPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(coordinatesProperty, generalCategory, "Coördinaten [m]", "Coördinaten van de hydraulische belastingenlocatie.", true); PropertyDescriptor resultProperty = dynamicProperties[resultPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(resultProperty, resultCategory, nameof(properties.Result), "", true); PropertyDescriptor targetProbabilityProperty = dynamicProperties[targetProbabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetProbabilityProperty, resultCategory, "Doelkans [1/jaar]", "De ingevoerde kans waarvoor het resultaat moet worden berekend.", true); PropertyDescriptor targetReliabilityProperty = dynamicProperties[targetReliabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetReliabilityProperty, resultCategory, "Betrouwbaarheidsindex doelkans [-]", "Betrouwbaarheidsindex van de ingevoerde kans waarvoor het resultaat moet worden berekend.", true); PropertyDescriptor calculatedProbabilityProperty = dynamicProperties[calculatedProbabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculatedProbabilityProperty, resultCategory, "Berekende kans [1/jaar]", "De berekende kans van voorkomen van het berekende resultaat.", true); PropertyDescriptor calculatedReliabilityProperty = dynamicProperties[calculatedReliabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculatedReliabilityProperty, resultCategory, "Betrouwbaarheidsindex berekende kans [-]", "Betrouwbaarheidsindex van de berekende kans van voorkomen van het berekende resultaat.", true); PropertyDescriptor convergenceProperty = dynamicProperties[convergencePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(convergenceProperty, resultCategory, "Convergentie", string.Empty, true); PropertyDescriptor calculateIllustrationPointsProperty = dynamicProperties[shouldCalculateIllustrationPointsIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculateIllustrationPointsProperty, illustrationPointsCategory, "Illustratiepunten inlezen", "Neem de informatie over de illustratiepunten op in het berekeningsresultaat."); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[governingWindDirectionIndex], illustrationPointsCategory, "Maatgevende windrichting", "De windrichting waarvoor de berekende betrouwbaarheidsindex het laagst is.", true); PropertyDescriptor alphaValuesProperty = dynamicProperties[alphaValuesIndex]; Assert.NotNull(alphaValuesProperty.Attributes[typeof(KeyValueElementAttribute)]); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(alphaValuesProperty, illustrationPointsCategory, "Invloedscoëfficiënten [-]", "Berekende invloedscoëfficiënten voor alle beschouwde stochasten.", true); PropertyDescriptor durationsProperty = dynamicProperties[durationsIndex]; Assert.NotNull(durationsProperty.Attributes[typeof(KeyValueElementAttribute)]); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(durationsProperty, illustrationPointsCategory, "Tijdsduren [uur]", "Tijdsduren waarop de stochasten betrekking hebben.", true); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[illustrationPointsIndex], illustrationPointsCategory, "Illustratiepunten", "De lijst van illustratiepunten voor de berekening.", true); }