private void AddWindowsPrice(BlueprintPriceReport report, IBlueprint aBlueprint) { int windowsCount = aBlueprint.GetOpenings().Count(o => o.GetComponentType().Equals(ComponentType.WINDOW)); float windowsPrice = costsNPrices.GetPrice((int)ComponentType.WINDOW); report.SetTotalPrice(ComponentType.WINDOW, windowsCount * windowsPrice); }
private void AddDoorsPrice(BlueprintPriceReport report, IBlueprint aBlueprint) { int doorsCount = aBlueprint.GetOpenings().Count(o => o.GetComponentType().Equals(ComponentType.DOOR)); float doorsPrice = costsNPrices.GetPrice((int)ComponentType.DOOR); report.SetTotalPrice(ComponentType.DOOR, doorsCount * doorsPrice); }
private void AddColumnsPrice(BlueprintPriceReport report, IBlueprint aBlueprint) { int columnsCount = aBlueprint.GetColumns().Count; float columnPrice = costsNPrices.GetPrice((int)ComponentType.COLUMN); report.SetTotalPrice(ComponentType.COLUMN, columnsCount * columnPrice); }
private void AddBeamsPrice(BlueprintPriceReport report, IBlueprint aBlueprint) { int beamsCount = aBlueprint.GetBeams().Count; float beamPrice = costsNPrices.GetPrice((int)ComponentType.BEAM); report.SetTotalPrice(ComponentType.BEAM, beamsCount * beamPrice); }
public void GetPriceBeamsTest() { BlueprintPriceReport report = reporter.GeneratePriceReport(toReport); float expectedResult = 225; float actualResult = report.GetTotalPrice(ComponentType.BEAM); Assert.AreEqual(expectedResult, actualResult); }
public void GetPriceWallsTest() { BlueprintPriceReport report = reporter.GeneratePriceReport(toReport); float expectedResult = 1000; float actualResult = report.GetTotalPrice(ComponentType.WALL); Assert.AreEqual(expectedResult, actualResult); }
public void GetPriceWindowsTest() { IPriceCostRepository pricesNcosts = new PriceCostRepository(); BlueprintPriceReport report = reporter.GeneratePriceReport(toReport); float expectedResult = 150; float actualResult = report.GetTotalPrice(ComponentType.WINDOW); Assert.AreEqual(expectedResult, actualResult); }
public BlueprintPriceReport GeneratePriceReport(IBlueprint aBlueprint) { BlueprintPriceReport report = new BlueprintPriceReport(); AddWallsPrice(report, aBlueprint); AddBeamsPrice(report, aBlueprint); AddColumnsPrice(report, aBlueprint); AddWindowsPrice(report, aBlueprint); AddDoorsPrice(report, aBlueprint); return(report); }
private void AddWallsPrice(BlueprintPriceReport report, IBlueprint aBlueprint) { float wallMetersCount = 0; foreach (Wall existent in aBlueprint.GetWalls()) { wallMetersCount += existent.Length(); } float wallPrice = costsNPrices.GetPrice((int)ComponentType.WALL); report.SetTotalPrice(ComponentType.WALL, wallMetersCount * wallPrice); }
//Auxiliar private void calulateCostsAndPrices() { IPriceCostRepository pricesNcosts = new PriceCostRepository(); BlueprintReportGenerator reportGenerator = new BlueprintReportGenerator(pricesNcosts); BlueprintCostReport costReport = reportGenerator.GenerateCostReport(selectedBluePrint); BlueprintPriceReport priceReport = reportGenerator.GeneratePriceReport(selectedBluePrint); if (CurrentSession.UserLogged.HasPermission(Permission.VIEW_COSTS)) { lblWallsTotalCost.Text = costReport.GetTotalCost(ComponentType.WALL) + ""; lblBeamsTotalCost.Text = costReport.GetTotalCost(ComponentType.BEAM) + ""; lblDoorsTotalCost.Text = costReport.GetTotalCost(ComponentType.DOOR) + ""; lblWindowsTotalCost.Text = costReport.GetTotalCost(ComponentType.WINDOW) + ""; lblColumnsTotalCost.Text = costReport.GetTotalCost(ComponentType.COLUMN) + ""; lblTotalCostSum.Text = (costReport.GetTotalCost(ComponentType.WALL) + costReport.GetTotalCost(ComponentType.BEAM) + costReport.GetTotalCost(ComponentType.DOOR) + costReport.GetTotalCost(ComponentType.WINDOW)) + costReport.GetTotalCost(ComponentType.COLUMN) + ""; } lblWallsPrice.Text = priceReport.GetTotalPrice(ComponentType.WALL) + ""; lblBeamsPrice.Text = priceReport.GetTotalPrice(ComponentType.BEAM) + ""; lblDoorsPrice.Text = priceReport.GetTotalPrice(ComponentType.DOOR) + ""; lblWindowsPrice.Text = priceReport.GetTotalPrice(ComponentType.WINDOW) + ""; lblColumnsTotalPrice.Text = priceReport.GetTotalPrice(ComponentType.COLUMN) + ""; lblTotalPriceSum.Text = (priceReport.GetTotalPrice(ComponentType.WALL) + priceReport.GetTotalPrice(ComponentType.BEAM) + priceReport.GetTotalPrice(ComponentType.DOOR) + priceReport.GetTotalPrice(ComponentType.WINDOW)) + priceReport.GetTotalPrice(ComponentType.COLUMN) + ""; }