public void It_can_add_another_discount() { var unit = new Discount(50); var other = new Discount(30); Assert.That(unit.Add(other).InCurrency(), Is.EqualTo(-0.8)); }
private void UpdateDiscount() { if (SelectedDiscount == null) { SelectedDiscount = Discount.Add(editorControl.Description, editorControl.Amount, editorControl.IsPercentage, editorControl.RequiresPermission, editorControl.ApplyToTicketItem, 0, 0); // By default IsActive is true (in Add), but encase not... if (!editorControl.IsActive) { SelectedDiscount.SetIsActive(false); SelectedDiscount.Update(); } AddDiscountToList(SelectedDiscount, true); buttonDelete.IsEnabled = true; } else { SelectedDiscount.SetDescription(editorControl.Description); SelectedDiscount.SetAmount(editorControl.Amount); SelectedDiscount.SetAmountIsPercentage(editorControl.IsPercentage); SelectedDiscount.SetRequiresPermission(editorControl.RequiresPermission); SelectedDiscount.SetApplyToTicketItem(editorControl.ApplyToTicketItem); SelectedDiscount.SetIsActive(editorControl.IsActive); SelectedDiscount.Update(); if (listBox1.SelectedItem != null) { var formattedListBoxItem = listBox1.SelectedItem as FormattedListBoxItem; if (formattedListBoxItem != null) { formattedListBoxItem.Text = editorControl.Description; } } } SetEditMode(false); }
public void CalculateTotal_ShouldReturnCorrectResult_WhenDiscountPerCart() { //Fixture setup var cart = new ShoppingCart(); var sut = cart.CreateCart(); var item = new CartItem(1, 17.5, .03, 0); var Item = new Item(); Item.Add(sut, item); Item.Add(sut, item); var Total = new Total(); var Discount = new Discount(); Discount.Add(sut, discountType.perCart, 0.25); var expected = 27.0375; //Excercise system sut = Total.Calculate(sut); var actual = sut.Total; //Verify outcome Assert.Equal(actual.ToString(), expected.ToString()); //Teardown }