public void Alter5() { // given Series series = TestObjects.GetSeries(); // when SeriesAssist.Alter(Operation.Constant, 0.0, series, 2, 1, 0); }
public void Alter7() { // given Series series = TestObjects.GetSeries(); const double OPERAND = 123.0; // when SeriesAssist.Alter(Operation.Exponentiation, OPERAND, series, 0, series.Points.Count - 1); }
private void OnPerformClick(object sender, EventArgs e) { Operation @operator = (Operation)UiControls.TryGetSelectedIndex(uiPnl_OperT_ComBx); double? userValue = (@operator == Operation.Positive || @operator == Operation.Negative) ? default(double) : Strings.TryGetValue(uiPnl_Val2_TxtBx.Text); if (userValue == null || Curve == null) { log.Info(MethodBase.GetCurrentMethod().Name + '(' + userValue + ',' + Curve + ')'); UpdateUiByPanelStateInfo(PanelStateInformation.InvalidUserValue); AppMessages.GridPreviewer.ExclamationOfImproperUserValue(); return; } int startIndex = UiControls.TryGetValue <int>(uiPnl_StartIdx_Num); int endIndex = UiControls.TryGetValue <int>(uiPnl_EndIdx_Num); Series seriesCopy = SeriesAssist.GetCopy(Curve); Operation operation = (Operation)uiPnl_OperT_ComBx.SelectedIndex; string signature = string.Empty; try { signature = MethodBase.GetCurrentMethod().Name + '(' + startIndex + ',' + endIndex + ',' + operation + ',' + userValue.Value + ')'; SeriesAssist.Alter(operation, userValue.Value, seriesCopy, startIndex, endIndex); } catch (NotFiniteNumberException ex) { log.Error(signature, ex); UpdateUiByPanelStateInfo(PanelStateInformation.OperationRevoked); AppMessages.GridPreviewer.ErrorOfInvalidCurvePoints(); return; } catch (Exception ex) { log.Fatal(signature, ex); UpdateUiByPanelStateInfo(PanelStateInformation.OperationRejected); AppMessages.GridPreviewer.ErrorOfPerformOperation(); return; } Curve.Points.Clear(); SeriesAssist.CopyPoints(seriesCopy, Curve); GridAssist.PopulateColumn(uiGrid_db_grid, y.Name, SeriesAssist.GetValues(Curve), VALUES_DECIMAL_PLACES); UpdateUiByRefreshingChart(); UpdateUiByPanelStateInfo(PanelStateInformation.PerformedAndRefreshed); log.Info(signature); }
public void Alter1() { // given const int START_INDEX = 1; const int END_INDEX = 3; IList <double> set = new List <double>() { 1, 2, 3, 4, 5 }; Series series1 = TestObjects.GetSeries(set); Series series2 = TestObjects.GetSeries(set); Series series3 = TestObjects.GetSeries(set); Series series4 = TestObjects.GetSeries(set); Series series5 = TestObjects.GetSeries(set); Series series6 = TestObjects.GetSeries(set); Series series7 = TestObjects.GetSeries(set); Series series8 = TestObjects.GetSeries(set); Series series9 = TestObjects.GetSeries(set); Series series10 = TestObjects.GetSeries(set); double operand1 = Math.Sqrt(2.0); double operand2 = Math.Sqrt(3.1); double operand3 = Math.Sqrt(Math.PI); double operand4 = Math.Sqrt(2.0 * Math.PI); double operand5 = Math.Sqrt(Math.Cos(0.5)); double operand6 = Math.Log10(10.123); double operand7 = Mathematics.Root(8.0, Math.Sqrt(2.0)); double operand8 = Mathematics.Reciprocal(Mathematics.Root(8.0, 2.0)); IList <double> expected1 = new List <double>() { set[0], set[1] + operand1, set[2] + operand1, set[3] + operand1, set[4] }; IList <double> expected2 = new List <double>() { set[0], set[1] - operand2, set[2] - operand2, set[3] - operand2, set[4] }; IList <double> expected3 = new List <double>() { set[0], set[1] * operand3, set[2] * operand3, set[3] * operand3, set[4] }; IList <double> expected4 = new List <double>() { set[0], set[1] / operand4, set[2] / operand4, set[3] / operand4, set[4] }; IList <double> expected5 = new List <double>() { set[0], Math.Pow(set[1], operand5), Math.Pow(set[2], operand5), Math.Pow(set[3], operand5), set[4] }; IList <double> expected6 = new List <double>() { set[0], Math.Log(set[1], operand6), Math.Log(set[2], operand6), Math.Log(set[3], operand6), set[4] }; IList <double> expected7 = new List <double>() { set[0], Mathematics.Root(set[1], operand7), Mathematics.Root(set[2], operand7), Mathematics.Root(set[3], operand7), set[4] }; IList <double> expected8 = new List <double>() { set[0], operand8, operand8, operand8, set[4] }; IList <double> expected10 = new List <double>() { set[0], -Math.Abs(set[1]), -Math.Abs(set[2]), -Math.Abs(set[3]), set[4] }; // when SeriesAssist.Alter(Operation.Addition, operand1, series1, START_INDEX, END_INDEX); SeriesAssist.Alter(Operation.Subtraction, operand2, series2, START_INDEX, END_INDEX); SeriesAssist.Alter(Operation.Multiplication, operand3, series3, START_INDEX, END_INDEX); SeriesAssist.Alter(Operation.Division, operand4, series4, START_INDEX, END_INDEX); SeriesAssist.Alter(Operation.Exponentiation, operand5, series5, START_INDEX, END_INDEX); SeriesAssist.Alter(Operation.Logarithmic, operand6, series6, START_INDEX, END_INDEX); SeriesAssist.Alter(Operation.Rooting, operand7, series7, START_INDEX, END_INDEX); SeriesAssist.Alter(Operation.Constant, operand8, series8, START_INDEX, END_INDEX); SeriesAssist.Alter(Operation.Positive, 0.0, series9, START_INDEX, END_INDEX); SeriesAssist.Alter(Operation.Negative, 0.0, series10, START_INDEX, END_INDEX); // then Assertions.SameValues(expected1, series1); Assertions.SameValues(expected2, series2); Assertions.SameValues(expected3, series3); Assertions.SameValues(expected4, series4); Assertions.SameValues(expected5, series5); Assertions.SameValues(expected6, series6); Assertions.SameValues(expected7, series7); Assertions.SameValues(expected8, series8); Assertions.SameValues(set, series9); Assertions.SameValues(expected10, series10); }
public void Alter6() { // when SeriesAssist.Alter(Operation.Constant, 0.0, null, 0, 0, 0); }