public override void ViewWillAppear(bool animated) { var button = UIButton.FromType(UIButtonType.RoundedRect); button.Frame = new RectangleF(210, 10, 100, 50); button.SetTitle("Update", UIControlState.Normal); var ypos = 0; button.TouchUpInside += delegate { var parkingLots = GetParkingLots(); var calculator = new CalculationHelper(); foreach(var parkingLot in parkingLots) { var distance = calculator.CalculateDistance(LocationUtility.CurrentLocation.Latitude, LocationUtility.CurrentLocation.Longitude, parkingLot.EntranceLat, parkingLot.EntranceLon); var label = new UILabel(new RectangleF(2, ypos, 300, 20)) { BackgroundColor = UIColor.Clear, LineBreakMode = UILineBreakMode.WordWrap, Lines = 0, Text = distance.ToString() }; this.View.AddSubview(label); ypos += 20; } ypos += 5; }; this.View.AddSubview(button); base.ViewWillAppear (animated); }
public void Calculator_Returns_Zero_If_Value_IsNull() { var result = CalculationHelper.Ratio(null, ValidSum); Assert.That(result, Is.EqualTo(0)); }
public void Calculator_Returns_Zero_If_Value_IsNot_MoreThan_Zero([Range(-1, 0)] int value) { var result = CalculationHelper.Ratio(value, ValidSum); Assert.That(result, Is.EqualTo(0)); }
public void Calculator_Returns_Ratio_If_Sum_And_Value_Are_MoreThan_Zero(int value, int sum, double ratio) { var result = CalculationHelper.Ratio(value, sum); Assert.That(result, Is.EqualTo(ratio)); }
public void AverageConversion_Calculation_ReturnsCorrectResult(int?salesQuantity, int?entranceCount, double?expected) { var actual = CalculationHelper.ConversionRate(salesQuantity, entranceCount); Assert.AreEqual(expected, actual); }
public void CaptureRate_Calculation_ReturnsCorrectResult(int?entranceCount, int?flowCount, double?expected) { var actual = CalculationHelper.CaptureRate(entranceCount, flowCount); Assert.AreEqual(expected, actual); }
public void PercentCalculateChange_ReturnsCorrectResult(double?originalNumber, double?newNumber, double?expected) { var actual = CalculationHelper.PercentCalculateChange(originalNumber, newNumber); Assert.AreEqual(expected, actual); }
protected IEnumerable <ReportPositionsModel> GetEntities(Filtering filtering) { var orderId = GetFilters(filtering); var result = new List <ReportPositionsModel>(); if (orderId != 0) { //TODO discuss with customer - take positions where proccessed amount not null (but take with 0) var termPositions = termPositionsManager.GetEntities(o => !o.DeleteDate.HasValue && o.Terms.OrderId == orderId && o.ProccessedAmount.HasValue).ToList(); var id = 0; foreach (var termPosition in termPositions) { //positions if (termPosition.ProccessedAmount.Value > 0) { id++; result.Add(PositionsToModel(id, termPosition.Positions, termPosition.ProccessedAmount.Value, termPosition.Terms.Date)); } //materials foreach (var material in termPosition.TermPositionMaterialRsps.Where(o => !o.DeleteDate.HasValue && o.Amount.HasValue)) { id++; var amount = material.Amount.Value; if (material.Materials.MaterialAmountTypes == MaterialAmountTypes.Meter) { if (material.Materials.Length != 0) { amount = amount / (double)material.Materials.Length.Value; } else { //todo } } result.Add(new ReportPositionsModel() { Id = id, amount = material.Amount.Value, description = material.Materials.Name, number = material.Materials.Number, createDate = termPosition.Terms.Date, amountType = material.Materials.MaterialAmountTypeString, price = material.Materials.Price.ToString("N2") + " EUR", totalPrice = CalculationHelper.CalculatePositionPrice(material.Materials.Price, amount, PaymentTypes.Standard).ToString("N2") + " EUR" }); } } //material positions without terms var materialPositionsWithoutTerms = positionsManager.GetEntities(o => o.OrderId == orderId && !o.DeleteDate.HasValue && !o.TermId.HasValue && o.MaterialId.HasValue && o.IsMaterialPosition).ToList(); foreach (var position in materialPositionsWithoutTerms) { id++; result.Add(PositionsToModel(id, position, position.Amount, position.ChangeDate /*todo check*/)); } //extra costs var termCosts = termCostsManager.GetEntities(o => !o.DeleteDate.HasValue && o.Terms.OrderId == orderId).ToList(); foreach (var termCost in termCosts) { id++; result.Add(new ReportPositionsModel() { Id = id, amount = 1, description = termCost.Name, createDate = termCost.ChangeDate /*todo check*/, amountType = "Pauschal", price = termCost.Price.ToString("N2") + " EUR", totalPrice = CalculationHelper.CalculatePositionPrice(termCost.Price, 1, PaymentTypes.Standard).ToString("N2") + " EUR" }); } } return(result.OrderBy(o => o.createDate)); }