private void GenerateInvoice() { var invoiceHtlmStringBuilder = new StringBuilder(); invoiceHtlmStringBuilder.Append("<table>"); for (var i = 0; i < _orderItems.Count; i++) { var currentItem = _orderItems[i]; var rentFee = new RentFee(currentItem.Equipment.Type, currentItem.RentDurationInDays).CalculateFee(); invoiceHtlmStringBuilder.Append("<tr>"); invoiceHtlmStringBuilder.Append($"<td width=20px> {i + 1} </td>"); invoiceHtlmStringBuilder.Append($"<td width=200px> {currentItem.Equipment.Name} </td>"); invoiceHtlmStringBuilder.Append($"<td width=200px> {currentItem.Equipment.Type} </td>"); invoiceHtlmStringBuilder.Append($"<td width=100px> {currentItem.RentDurationInDays} days </td>"); invoiceHtlmStringBuilder.Append($"<td width=250px> {rentFee}$ </td>"); invoiceHtlmStringBuilder.Append("</tr>"); _priceSum += rentFee; } invoiceHtlmStringBuilder.Append($"<tr> <td width=100px>Total price: {_priceSum}$ </td> </tr>"); invoiceHtlmStringBuilder.Append("</table>"); _invoiceHtmlString = new HtmlString(invoiceHtlmStringBuilder.ToString()); }
public string GenerateInvoiceText() { var invoiceStringBuilder = new StringBuilder($"Invoice for order id: {_orderId}\n"); for (var i = 0; i < _orderItems.Count; i++) { var currentItem = _orderItems[i]; var rentFee = new RentFee(currentItem.Equipment.Type, currentItem.RentDurationInDays).CalculateFee(); invoiceStringBuilder.Append($"{i + 1}.\t{currentItem.Equipment.Name}\t{currentItem.Equipment.Type}\t{currentItem.RentDurationInDays}\t{rentFee}$\n"); } invoiceStringBuilder.Append($"Total price: {_priceSum}$"); return(invoiceStringBuilder.ToString()); }
public void CalculateSpecializedFeeTest() { var specializedRentFee = new RentFee(EquipmentType.Specialized, 1); Assert.AreEqual(specializedRentFee.CalculateFee(), 180.0f); }
public void CalculateHeavyFeeTest() { var heavyRentFee = new RentFee(EquipmentType.Heavy, 1); Assert.AreEqual(heavyRentFee.CalculateFee(), 160.0f); }
public void CalculateRegularFeeTest() { var regularRentFee = new RentFee(EquipmentType.Regular, 1); Assert.AreEqual(regularRentFee.CalculateFee(), 220.0f); }