/// <summary> /// Initializes an instance of SalesQuote with a vehicle price, trade-in amount, sales tax rate, /// no accessories chosen and no exterior finish chosen. /// </summary> /// <param name="vehicleSalePrice">The Sale price of the vehicle.</param> /// <param name="tradeInAmount">The value of the vehicle trade-in.</param> /// <param name="salesTaxRate">The sales tax rate.</param> /// <exception cref="ArgumentOutOfRangeException">Throw when the vehicle sale price, trade in amount, and sales tax rate is less than or equal to 0, and sales tax rate is greater than 1.</exception> public SalesQuote(decimal vehicleSalePrice, decimal tradeInAmount, decimal salesTaxRate) { if (this.vehicleSalePrice <= 0) { throw new ArgumentOutOfRangeException("vehicleSalePrice", "The argument cannot be less than or equal to 0."); } else if (this.tradeInAmount <= 0) { throw new ArgumentOutOfRangeException("tradeInAmount", "The argument cannot be less than or equal to 0."); } else if (this.salesTaxRate <= 0) { throw new ArgumentOutOfRangeException("salesTaxRate", "The argument cannot be less than or equal to 0."); } else if (this.salesTaxRate > 1) { throw new ArgumentOutOfRangeException("salesTaxRate", "The argument cannot be greater than 1."); } else { this.vehicleSalePrice = vehicleSalePrice; this.tradeInAmount = tradeInAmount; this.salesTaxRate = salesTaxRate; accessoriesChosen = Accessories.None; exteriorFinishChosen = ExteriorFinish.None; } }
public void SalesQuote_Test() { decimal vehicleSalePrice = 0.1M; decimal tradeInAmount = 0.2M; decimal salesTaxRate = 0.1M; Accessories accessoriesChosen = new Accessories(); ExteriorFinish exteriorFinishChosen = new ExteriorFinish(); SalesQuote salesQuote = new SalesQuote(vehicleSalePrice, tradeInAmount, salesTaxRate, accessoriesChosen, exteriorFinishChosen); decimal expectedVehicleSalePrice = 0.1M; decimal expectedTradeInAmount = 0.2M; decimal expectedSalesTaxRate = 0.1M; Accessories expectedAccessoriesChosen = new Accessories(); ExteriorFinish expectedExteriorFinishChosen = new ExteriorFinish(); PrivateObject target = new PrivateObject(salesQuote); decimal actualVehicleSalePrice = (decimal)target.GetField("vehicleSalePrice"); decimal actualTradeInAmount = (decimal)target.GetField("tradeInAmount"); decimal actualSalesTaxRate = (decimal)target.GetField("salesTaxRate"); Accessories actualAccessoriesChosen = (Accessories)target.GetField("accessoriesChosen"); ExteriorFinish actualExteriorFinishChosen = (ExteriorFinish)target.GetField("exteriorFinishChosen"); Assert.AreEqual(expectedSalesTaxRate, actualSalesTaxRate); Assert.AreEqual(expectedTradeInAmount, actualTradeInAmount); Assert.AreEqual(expectedVehicleSalePrice, actualVehicleSalePrice); Assert.AreEqual(expectedAccessoriesChosen, actualAccessoriesChosen); Assert.AreEqual(expectedExteriorFinishChosen, actualExteriorFinishChosen); }
public void Constructor_VehicleSalesPrice_TradeInAmount_SalesTaxRate_Accessories_Finish_Test() { //Arrange decimal vehicleSalesPrice = 10000; decimal tradeInAmount = 2000; decimal salesTaxRate = 0.1m; Accessories accessories = Accessories.LeatherInterior; ExteriorFinish finish = ExteriorFinish.Custom; SalesQuote salesQuote = new SalesQuote(vehicleSalesPrice, tradeInAmount, salesTaxRate, accessories, finish); PrivateObject target = new PrivateObject(salesQuote); //Act decimal expectedVehicleSalesPrice = 10000; decimal expectedTradeInAmount = 2000; decimal expectedSalesTaxRate = 0.1m; Accessories expectedAccessories = Accessories.LeatherInterior; ExteriorFinish expectedFinish = ExteriorFinish.Custom; decimal actualVehicleSalesPrice = (decimal)target.GetField("vehicleSalesPrice"); decimal actualTradeInAmount = (decimal)target.GetField("tradeInAmount"); Accessories actualAccessories = (Accessories)target.GetField("accessoriesChosen"); ExteriorFinish actualFinish = (ExteriorFinish)target.GetField("exteriorFinishChosen"); decimal actualSalesRate = 0.1m; //Assert Assert.AreEqual(expectedVehicleSalesPrice, actualVehicleSalesPrice); Assert.AreEqual(expectedTradeInAmount, actualTradeInAmount); Assert.AreEqual(expectedAccessories, actualAccessories); Assert.AreEqual(expectedFinish, actualFinish); Assert.AreEqual(expectedSalesTaxRate, actualSalesRate); }
public void GetFinishCost__Test() { ExteriorFinish exteriorFinishChosen = new ExteriorFinish(); SalesQuote salesQuote = new SalesQuote(0.1M, 0.2M, 0.3M, Accessories.None, exteriorFinishChosen); decimal expectedFinishCost; decimal standard = 202.02M; decimal pearlized = 404.04M; decimal custom = 606.06M; switch (exteriorFinishChosen) { case ExteriorFinish.Custom: expectedFinishCost = custom; break; case ExteriorFinish.Pearlized: expectedFinishCost = pearlized; break; case ExteriorFinish.Standard: expectedFinishCost = standard; break; default: expectedFinishCost = 0.00M; break; } decimal actualFinishCost = salesQuote.FinishCost; Assert.AreEqual(expectedFinishCost, actualFinishCost); }
public void SetTradeInAmountSpecial_Test() { //Arrange decimal vehicleSalesPrice = 10000; decimal tradeInAmount = 2000; decimal salesTaxRate = 0.1m; Accessories accessories = Accessories.LeatherInterior; ExteriorFinish finish = ExteriorFinish.Custom; SalesQuote salesQuote = new SalesQuote(vehicleSalesPrice, tradeInAmount, salesTaxRate, accessories, finish); //Act decimal expcetedTradeInAmount = 2000; //Assert try { salesQuote.TradeInAmount = -1000; Assert.Fail("Did not throw ArgumentOutOfRangeException as expected."); } catch (ArgumentOutOfRangeException) { PrivateObject abc = new PrivateObject(salesQuote); decimal actualTradeInAmount = (decimal)abc.GetField("tradeInAmount"); Assert.AreEqual(expcetedTradeInAmount, actualTradeInAmount); } }
/// <summary> /// Initializes an instance of SalesQuote with a vehicle price, /// trade-in value, sales tax rate, accessories chosen and exterior finish chosen. /// </summary> /// <param name="vehicleSalesPrice">The selling price of the vehicle being sold.</param> /// <param name="tradeInAmount">The amount offered to the customer for the trade in of their vehicle.</param> /// <param name="salesTaxRate">The tax rate applied to the sale of a vehicle.</param> /// <param name="accessoriesChosen">The value of the chosen accessories.</param> /// <param name="exteriorFinishChosen">The value of the chosen exterior finish.</param> /// <exception cref="System.ArgumentOutOfRangeException">Thrown when argument cannot be less than or equal ot 0.</exception> public SalesQuote(decimal vehicleSalesPrice, decimal tradeInAmount, decimal salesTaxRate, Accessories accessoriesChosen, ExteriorFinish exteriorFinishChosen) { if (vehicleSalesPrice <= 0) { throw new ArgumentOutOfRangeException("The argument cannot be less than or equal to 0."); } if (tradeInAmount < 0) { throw new ArgumentOutOfRangeException("The argument cannot be less than 0."); } if (salesTaxRate < 0) { throw new ArgumentOutOfRangeException("The argument cannot be less than 0."); } else if (salesTaxRate > 1) { throw new ArgumentOutOfRangeException("The argument cannot be greater than 0."); } this.vehicleSalesPrice = vehicleSalesPrice; this.tradeInAmount = tradeInAmount; this.salesTaxRate = salesTaxRate; this.accessoriesChosen = accessoriesChosen; this.exteriorFinishChosen = exteriorFinishChosen; }
/// <summary> /// Initializes an instance of SalesQuote with a vehicle price, trade-in value, sales tax rate, /// accessories chosen and exterior finish chosen. /// </summary> /// <param name="vehicleSalePrice">Sale price of the vehicle.</param> /// <param name="tradeInAmount">Value trade-in.</param> /// <param name="salesTaxRate">Sales tax rate.</param> /// <param name="accessoriesChosen">Chosen accessories.</param> /// <param name="exteriorFinishChosen">Chosen exterior finish.</param> /// <exception cref="ArgumentOutOfRangeException">Throw when the vehicle sale price, trade in amount, and sales tax rate is less than or equal to 0, or when sales tax rate is greater than 1.</exception> /// <exception cref="System.ComponentModel.InvalidEnumArgumentException">Throw when the value is an invalid enumeration value.</exception> public SalesQuote(decimal vehicleSalePrice, decimal tradeInAmount, decimal salesTaxRate, Accessories accessoriesChosen, ExteriorFinish exteriorFinishChosen) { if (this.vehicleSalePrice <= 0) { throw new ArgumentOutOfRangeException("vehicleSalePrice", "The argument cannot be less than or equal to 0."); } else if (this.tradeInAmount <= 0) { throw new ArgumentOutOfRangeException("tradeInAmount", "The argument cannot be less than or equal to 0."); } else if (this.salesTaxRate <= 0) { throw new ArgumentOutOfRangeException("salesTaxRate", "The argument cannot be less than or equal to 0."); } else if (this.salesTaxRate > 1) { throw new ArgumentOutOfRangeException("salesTaxRate", "The argument cannot be greater than 1."); } else if (!Enum.IsDefined(typeof(Accessories), accessoriesChosen)) { throw new System.ComponentModel.InvalidEnumArgumentException("The value is an invalid enumeration value."); } else if (!Enum.IsDefined(typeof(ExteriorFinish), exteriorFinishChosen)) { throw new System.ComponentModel.InvalidEnumArgumentException("The value is an invalid enumeration value."); } else { this.vehicleSalePrice = vehicleSalePrice; this.tradeInAmount = tradeInAmount; this.salesTaxRate = salesTaxRate; this.accessoriesChosen = accessoriesChosen; this.exteriorFinishChosen = exteriorFinishChosen; } }
public void GetExteriorChosen_Standard_Test() { SalesQuote salesQuote = new SalesQuote(0.1M, 0.2M, 0.3M, Accessories.None, ExteriorFinish.Standard); ExteriorFinish expectedExteriorChosen = ExteriorFinish.Standard; ExteriorFinish actualExteriorChosen = salesQuote.ExteriorFinishChosen; Assert.AreEqual(expectedExteriorChosen, actualExteriorChosen); }
/// <summary> /// Initializes a new instance of the SalesQuote class with a vehicle price, trade-in amount, sales tax rate, accessories chosen and exterior finish chosen. /// </summary> /// <param name="vehicleSalePrice"> The selling price of the vehicle being sold. </param> /// <param name="tradeInAmount"> The amount offered to the customer for the trade in of their vehicle. </param> /// <param name="salesTaxRate"> The tax rate applied to the sale of a vehicle. </param> /// <param name="accessoriesChosen"> The value of the chosen accessories. </param> /// <param name="exteriorFinishChosen"> The value of the chosen exterior finish. </param> public SalesQuote(decimal vehicleSalePrice, decimal tradeInAmount, decimal salesTaxRate, Accessories accessoriesChosen, ExteriorFinish exteriorFinishChosen) { this.vehicleSalePrice = vehicleSalePrice; this.tradeInAmount = tradeInAmount; this.salesTaxRate = salesTaxRate; this.accessoriesChosen = accessoriesChosen; this.exteriorFinishChosen = exteriorFinishChosen; }
/// <summary> /// Construct a new SalesQuote /// </summary> /// <param name="vehicleSalePrice">The vehicle sale price</param> /// <param name="tradeInValue">The trade in value</param> /// <param name="salesTaxRate">The sales tax rate</param> /// <param name="accessoriesChosen">The accessories chosen</param> /// <param name="exteriorFinishChosen">The exterior finish chosen</param> public SalesQuote(decimal vehicleSalePrice, decimal tradeInValue, decimal salesTaxRate, Accessories accessoriesChosen, ExteriorFinish exteriorFinishChosen) { _vehicleSalePrice = vehicleSalePrice; _tradeInValue = tradeInValue; _salesTaxRate = salesTaxRate; _accessoriesChosen = accessoriesChosen; _exteriorFinishChosen = exteriorFinishChosen; }
public void SalesQuote_VehicleSalesPrice_Greater_Exception_Test() { decimal vehicleSalesPrice = 0.1M; decimal tradeInAmount = 0.3M; decimal salesTaxRate = 4M; Accessories accessories = Accessories.All; ExteriorFinish exteriorFinish = ExteriorFinish.Custom; SalesQuote actualSalesQuote = new SalesQuote(vehicleSalesPrice, tradeInAmount, salesTaxRate, accessories, exteriorFinish); }
public void Constructor1_InvalidExteriorFinish_Exception() { // Arrange decimal vehicleSalePrice = 50000, tradeInAmount = 10000, salesTaxRate = 0.5M; Accessories accessoriesChosen = Accessories.All; ExteriorFinish exteriorFinishChosen = (ExteriorFinish)20; // Act SalesQuote customerQuote = new SalesQuote(vehicleSalePrice, tradeInAmount, salesTaxRate, accessoriesChosen, exteriorFinishChosen); }
public void AccessoriesChosenPropertySet_InvalidAccessories_Exception() { // Arrange decimal vehicleSalePrice = 50000M, tradeInAmount = 10000M, salesTaxRate = 0.5M; Accessories accessoriesChosen = (Accessories)99; ExteriorFinish exteriorFinishChosen = ExteriorFinish.Custom; // Act SalesQuote customerQuote = new SalesQuote(vehicleSalePrice, tradeInAmount, salesTaxRate, accessoriesChosen, exteriorFinishChosen); }
public void Constructor1_NegativeSalesTaxRate_Exception() { // Arrange decimal vehicleSalePrice = 50000, tradeInAmount = 10000, salesTaxRate = -10M; Accessories accessoriesChosen = Accessories.All; ExteriorFinish exteriorFinishChosen = ExteriorFinish.Custom; // Act SalesQuote customerQuote = new SalesQuote(vehicleSalePrice, tradeInAmount, salesTaxRate, accessoriesChosen, exteriorFinishChosen); }
public void SetExteriorChosen_Standard_Test() { SalesQuote salesQuote = new SalesQuote(0.1M, 0.2M, 0.3M, Accessories.All, ExteriorFinish.Standard); ExteriorFinish expectedExteriorChosen = ExteriorFinish.Standard; salesQuote.ExteriorFinishChosen = ExteriorFinish.Standard; PrivateObject target = new PrivateObject(salesQuote); ExteriorFinish actualExteriorChosen = (ExteriorFinish)target.GetField("exteriorFinishChosen"); Assert.AreEqual(expectedExteriorChosen, actualExteriorChosen); }
public void Constructor_TradeInAmount_SalesTaxRate_Accessories_Finish_VehicleSalesPriceLessThanZero_Test() { //Arrange decimal vehicleSalesPrice = -1; decimal tradeInAmount = 2000; decimal salesTaxRate = 0.1m; Accessories accessories = Accessories.LeatherInterior; ExteriorFinish finish = ExteriorFinish.Custom; SalesQuote salesQuote = new SalesQuote(vehicleSalesPrice, tradeInAmount, salesTaxRate, accessories, finish); //Act //Assert }
public void Constructor_VehicleSalesPrice_TradeInAmount_SalesTaxRateMoreThanOne_Test() { //Arrange decimal vehicleSalesPrice = 10000; decimal tradeInAmount = 2000; decimal salesTaxRate = 1.1m; Accessories accessories = Accessories.None; ExteriorFinish finish = ExteriorFinish.None; SalesQuote salesQuote = new SalesQuote(vehicleSalesPrice, tradeInAmount, salesTaxRate, accessories, finish); //Act //Assert }
public void FinishCostPropertyGet_InvalidFinishCost_Exception() { // Arrange decimal vehicleSalePrice = 50000M, tradeInAmount = 10000M, salesTaxRate = 0.5M; Accessories accessoriesChosen = Accessories.LeatherInterior; ExteriorFinish exteriorFinishChosen = (ExteriorFinish)99; SalesQuote customerQuote = new SalesQuote(vehicleSalePrice, tradeInAmount, salesTaxRate, accessoriesChosen, exteriorFinishChosen); // Act decimal actual = customerQuote.FinishCost; }
public void VehicleSalePricePropertySet_ZeroVehicleSalePrice_Exception() { // Arrange decimal vehicleSalePrice = 0, tradeInAmount = 10000M, salesTaxRate = 0.5M; Accessories accessoriesChosen = Accessories.All; ExteriorFinish exteriorFinishChosen = ExteriorFinish.Custom; SalesQuote customerQuote = new SalesQuote(vehicleSalePrice, tradeInAmount, salesTaxRate, accessoriesChosen, exteriorFinishChosen); // Act decimal actual = customerQuote.VehicleSalePrice; }
public void GetExteriorFinishChosen_Test() { //Arrange SalesQuote salesQuote = new SalesQuote(10000, 2000, 0.1m, Accessories.LeatherInterior, ExteriorFinish.Pearlized); //Act ExteriorFinish expectedExteriorFinishChosen = ExteriorFinish.Pearlized; //Assert PrivateObject target = new PrivateObject(salesQuote); ExteriorFinish actualExteriorFinishChosen = (ExteriorFinish)target.GetField("exteriorFinishChosen"); Assert.AreEqual(expectedExteriorFinishChosen, actualExteriorFinishChosen); }
/// <summary> /// Sets the chosen exterior finish. /// </summary> private void ExteriorFinChosen() { if (radBtnStandard.Checked) { exteriorFinish = ExteriorFinish.Standard; } else if (radBtnPearlized.Checked) { exteriorFinish = ExteriorFinish.Pearlized; } else if (radBtnCustomized.Checked) { exteriorFinish = ExteriorFinish.Custom; } }
public void TotalTest() { Decimal vehicleSalePrice = 13456.12m; // TODO: Initialize to an appropriate value Decimal tradeInValue = 10123.23m; // TODO: Initialize to an appropriate value Decimal salesTaxRate = .13m; // TODO: Initialize to an appropriate value Accessories accessoriesChosen = Accessories.None; // TODO: Initialize to an appropriate value ExteriorFinish exteriorFinishChosen = ExteriorFinish.None; // TODO: Initialize to an appropriate value SalesQuote target = new SalesQuote(vehicleSalePrice, tradeInValue, salesTaxRate, accessoriesChosen, exteriorFinishChosen); // TODO: Initialize to an appropriate value Decimal actual; actual = target.Total; Assert.AreEqual(target.SalesTax + target.SubTotal, actual); }
public void SalesQuoteConstructorTest() { Decimal vehicleSalePrice = 13456.12m; // TODO: Initialize to an appropriate value Decimal tradeInValue = 10123.23m; // TODO: Initialize to an appropriate value Decimal salesTaxRate = .13m; // TODO: Initialize to an appropriate value Accessories accessoriesChosen = Accessories.ComputerNavigation; // TODO: Initialize to an appropriate value ExteriorFinish exteriorFinishChosen = ExteriorFinish.Custom; // TODO: Initialize to an appropriate value SalesQuote_Accessor target = new SalesQuote_Accessor(vehicleSalePrice, tradeInValue, salesTaxRate, accessoriesChosen, exteriorFinishChosen); Assert.AreEqual(target._vehicleSalePrice, vehicleSalePrice); Assert.AreEqual(target._tradeInValue, tradeInValue); Assert.AreEqual(target._salesTaxRate, salesTaxRate); Assert.AreEqual(target._accessoriesChosen, accessoriesChosen); Assert.AreEqual(target._exteriorFinishChosen, exteriorFinishChosen); }
public void AccessoryCostAllTest() { Decimal vehicleSalePrice = 13456.12m; // TODO: Initialize to an appropriate value Decimal tradeInValue = 10123.23m; // TODO: Initialize to an appropriate value Decimal salesTaxRate = .13m; // TODO: Initialize to an appropriate value Accessories accessoriesChosen = Accessories.All; // TODO: Initialize to an appropriate value ExteriorFinish exteriorFinishChosen = ExteriorFinish.Custom; // TODO: Initialize to an appropriate value SalesQuote target = new SalesQuote(vehicleSalePrice, tradeInValue, salesTaxRate, accessoriesChosen, exteriorFinishChosen); // TODO: Initialize to an appropriate value Decimal actual; actual = target.AccessoryCost; Assert.AreEqual(Accessory.STEREO_SYSTEM + Accessory.LEATHER_INTERIOR + Accessory.COMPUTER_NAVIGATION, actual); }
public void FinishCostCustomTest() { Decimal vehicleSalePrice = 13456.12m; // TODO: Initialize to an appropriate value Decimal tradeInValue = 10123.23m; // TODO: Initialize to an appropriate value Decimal salesTaxRate = .13m; // TODO: Initialize to an appropriate value Accessories accessoriesChosen = Accessories.All; // TODO: Initialize to an appropriate value ExteriorFinish exteriorFinishChosen = ExteriorFinish.Custom; // TODO: Initialize to an appropriate value SalesQuote target = new SalesQuote(vehicleSalePrice, tradeInValue, salesTaxRate, accessoriesChosen, exteriorFinishChosen); // TODO: Initialize to an appropriate value Decimal actual; actual = target.FinishCost; Assert.AreEqual(Finish.CUSTOM, actual); }
public void Constructor2_NoFinishChosen_ReturnState() { // Arrange decimal vehicleSalePrice = 60000, tradeInAmount = 20000, salesTaxRate = 0.5M; SalesQuote customerQuote = new SalesQuote(vehicleSalePrice, tradeInAmount, salesTaxRate); PrivateObject target = new PrivateObject(customerQuote); // Act ExteriorFinish actual = (ExteriorFinish)target.GetField("exteriorFinishChosen"); // Assert ExteriorFinish expected = ExteriorFinish.None; Assert.AreEqual(expected, actual); }
public void AccessoriesCostPropertyGet_StereoAndCompNav_ReturnTotal() { // Arrange decimal vehicleSalePrice = 50000M, tradeInAmount = 10000M, salesTaxRate = 0.5M; Accessories accessoriesChosen = Accessories.StereoAndNavigation; ExteriorFinish exteriorFinishChosen = ExteriorFinish.Custom; SalesQuote customerQuote = new SalesQuote(vehicleSalePrice, tradeInAmount, salesTaxRate, accessoriesChosen, exteriorFinishChosen); // Act decimal actual = customerQuote.AccessoriesCost; // Assert decimal expected = 505.05M + 1515.15M; Assert.AreEqual(expected, actual); }
public void Constructor1_AccessoriesChosen_ReturnState() { // Arrange decimal vehicleSalePrice = 60000, tradeInAmount = 20000, salesTaxRate = 0.5M; Accessories accessoriesChosen = Accessories.All; ExteriorFinish exteriorFinishChosen = ExteriorFinish.Custom; SalesQuote customerQuote = new SalesQuote(vehicleSalePrice, tradeInAmount, salesTaxRate, accessoriesChosen, exteriorFinishChosen); PrivateObject target = new PrivateObject(customerQuote); // Act Accessories actual = (Accessories)target.GetField("accessoriesChosen"); // Assert Accessories expected = Accessories.All; Assert.AreEqual(expected, actual); }
public void FinishCostPropertyGet_None_ReturnTotal() { // Arrange decimal vehicleSalePrice = 50000M, tradeInAmount = 10000M, salesTaxRate = 0.5M; Accessories accessoriesChosen = Accessories.LeatherInterior; ExteriorFinish exteriorFinishChosen = ExteriorFinish.None; SalesQuote customerQuote = new SalesQuote(vehicleSalePrice, tradeInAmount, salesTaxRate, accessoriesChosen, exteriorFinishChosen); // Act decimal actual = customerQuote.FinishCost; // Assert decimal expected = 0.00M; Assert.AreEqual(expected, actual); }
public void TradeInAmountPropertyGet_ReturnState() { // Arrange decimal vehicleSalePrice = 50000M, tradeInAmount = 10000M, salesTaxRate = 0.5M; Accessories accessoriesChosen = Accessories.All; ExteriorFinish exteriorFinishChosen = ExteriorFinish.Custom; SalesQuote customerQuote = new SalesQuote(vehicleSalePrice, tradeInAmount, salesTaxRate, accessoriesChosen, exteriorFinishChosen); // Act decimal actual = customerQuote.TradeInAmount; // Assert decimal expected = 10000M; Assert.AreEqual(expected, actual); }