[InlineData(50.0, 10.0, 0, false, false, 16.653)] //to center public void TestCalculateLimitingDistance(double BAForFPS, double dbh, int slopePCT, bool isVar, bool isFace, double expected) { int sigDec = 3; string measureTo = (isFace) ? LimitingDistanceCalculator.MEASURE_TO_FACE : LimitingDistanceCalculator.MEASURE_TO_CENTER; var ld = LimitingDistanceCalculator.CalculateLimitingDistance(BAForFPS, dbh, slopePCT, isVar, measureTo); ld = Math.Round(ld, sigDec); expected = Math.Round(expected, 3); ld.Should().Be(expected); }
public FormLimitingDistance() { InitializeComponent(); Calculator = new LimitingDistanceCalculator(); foreach (var i in LimitingDistanceCalculator.MEASURE_TO_OPTIONS) { _measureToCB.Items.Add(i); } //initialize form state this._calculateBTN.Enabled = false; #if NetCF if (ViewController.PlatformType == FMSC.Controls.PlatformType.WM) { this.components = this.components ?? new System.ComponentModel.Container(); this._sip = new Microsoft.WindowsCE.Forms.InputPanel(); this.components.Add(_sip); this._sip.EnabledChanged += new EventHandler(_sip_EnabledChanged); _ceControlPanel.Visible = false; var mainMenu1 = new System.Windows.Forms.MainMenu(); var _cancel_MI = new System.Windows.Forms.MenuItem(); var _calculate_MI = new System.Windows.Forms.MenuItem(); // // mainMenu1 // mainMenu1.MenuItems.Add(_cancel_MI); mainMenu1.MenuItems.Add(_calculate_MI); // // _cancel_MI // _cancel_MI.Text = "Cancel"; _cancel_MI.Click += new System.EventHandler(this._cancelMI_Click); // // _calculate_MI // _calculate_MI.Text = "Calculate"; _calculate_MI.Click += new System.EventHandler(this._calculateBTN_Click); Menu = mainMenu1; } else { this.WindowState = System.Windows.Forms.FormWindowState.Maximized; } #else StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; #endif }
public void GenerateReportTest() { var calculator = new LimitingDistanceCalculator(); calculator.GenerateReport().Should().BeNullOrEmpty("Because calculator with default values should generate a empty report"); calculator.SlopeDistance = 1; calculator.DBH = 1; calculator.BAForFPSize = 1; calculator.MeasureTo = LimitingDistanceCalculator.MEASURE_TO_FACE; calculator.Recalculate(); calculator.LimitingDistance.Should().BeGreaterThan(0, "Because we need to confirm that the calculator is setup to generate a positive limiting distance"); var report = calculator.GenerateReport(); report.Should().NotBeNullOrWhiteSpace(); report.Should().NotContain("Azimuth", "Because azimuth should not be included if not greater than 0"); calculator.Azimuth = 1; report = calculator.GenerateReport(); report.Should().Contain("Azimuth"); }
//for tree to be in slope distance (first value) must be less than or equal to limiting distance (second value) //both values are round to two decimal places //here we test edge cases where both values should be determined to be equal public void TestDeterminTreeInOrOut(double slopeDistance, double limitingDistance, bool expectedResult) { LimitingDistanceCalculator.DeterminTreeInOrOut(slopeDistance, limitingDistance).Should().Be(expectedResult); }